Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Matthew Scerri 4 posts 45 karma points
    Feb 26, 2014 @ 11:05
    Matthew Scerri
    0

    Passing parameters in links to Umbraco nodes - Best practices

    Hello,

    First things first, I've only been fiddling around with Umbraco for a few days so apologies if this is a basic question. I did try to search around on the web and in the forum and couldn't find an answer though.

     

    Essentially, one of the new things I'm trying to discover with umbraco is what the best way to pass a parameter would be.

     

    I am currently setting up a few pages that feed data to/from a separate database (i.e not where umbraco is stored). I want to be able to pass parameters around to be able to carry out certain operations.

     

    Let's take an example where I have a Node with a page template that gets a list of items from a db (ItemsDisplayPage). I want to place a simple link in this page to another Node that displays an edit form (EditPage) for this item. Obviously I'd need to pass a parameter with the item id so that the controller can know which item needs to be edited. What would be the best way to achieve this be?

     

    • ItemsDisplayPage - Lists all items (1 property, Content Picker that points to ItemEditPage node)
    • ItemEditPage - Opens up a form with the details for a single item

     

    So far, the only solution we found was to set up the ItemsDisplayPage get the EditPage node, grab it's URL and manually appending the item Id as a query string parameter. Is this the right approach, and if so, are there any neater ways of doing it? (such as the Url.Action helper with MVC?) I can't find plenty of examples. Another approach I think will work just as well is to use the TempData / ViewData but I don't think it would be ideal to use that for such a case?

     

    I have created custom controllers for both items so that the ItemsDisplayPage fetches the data from the database on load, gets the Url for the EditPage from the Id (which is supplied by the ContentPicker field) and constructs the links. The custom controller for the ItemEditPage reads the parameter via the QueryString.

     

    I understand if this may not be a clear question, but not sure what I can elaborate on at this point. If so please feel free to let me know where to elborate.

     

    Thanks for your help!

     

    Matthew

  • Rahul Patel 8 posts 80 karma points
    Sep 12, 2017 @ 04:40
    Rahul Patel
    0

    Did you ever figure out what's the right way to do this?

Please Sign in or register to post replies

Write your reply to:

Draft