Copied to clipboard

Flag this post as spam?

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


  • Mark Watson 56 posts 126 karma points
    28 days ago
    Mark Watson
    0

    How do you sort a partial view

    I have created a partial view "Physicians" that displays a list of all active members. How do I display the members for each state. The state selection is controled by a drop down menu and displayed in the partial view by the var selectedState.

    <h3>New South Wales</h3>
    

    @Html.Partial("Physicians")

        <h3>Queensland</h3>
    

    @Html.Partial("Physicians")

  • pranjal 75 posts 186 karma points
    28 days ago
    pranjal
    0

    Use Umbraco Razor Sort nodes in ascending and descending order

  • Mark Watson 56 posts 126 karma points
    27 days ago
    Mark Watson
    0

    Thanks Pranjal

    How do i do that i am new to Umbraco?

  • Nathan Woulfe 280 posts 974 karma points MVP c-trib
    27 days ago
    Nathan Woulfe
    0

    Hi Mark

    I'm guessing there's logic feeding the list of physicians back to your partial view (or living in the view itself)? From your main view, you could pass a parameter to the partial to use as a filter for the complete set of members.

    @Html.Partial("Physicians", new ViewDataDictionary({{ state = "Queensland" }}));
    

    Which would be available in the partial as

    @ViewData["state"]
    

    Another option would be Html.Action:

    @Html.Action("MyMethodName", "MyController", new { state = "Queensland" });
    

    Which can still use the same Physicians partial UI, but would move the logic into MyMethodName on MyController, where state would be passed in as a parameter of MyMethodName. From there, you return a model to the Physicians partial, and enjoy strongly-type goodness in your UI

Please Sign in or register to post replies

Write your reply to:

Draft