Copied to clipboard

Flag this post as spam?

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


  • Sean 141 posts 179 karma points
    Feb 18, 2012 @ 04:47
    Sean
    0

    rendering dynamic partial views with razor v5

    Hi There,

    I'm new to v5 and razor. I'm wanting to load partial views based on page name. However I'm not sure what the best approach for this is?

    I would like to pass this view into the body of the document.

    @Html.RenderPartial(/mypath/mpartialview);

    Any ideas how I can do this?

    Sean

  • Sean 141 posts 179 karma points
    Feb 19, 2012 @ 04:41
    Sean
    0

    Solved it myself.

     

     var currentPage = @DynamicModel;
        var rootNode = currentPage.AncestorsOrSelf.Last();
        var theCurrentPageName = @String.Format("{0}{1}{2}","~/Views/Umbraco/Partial/",@currentPage.Name,"Partial.cshtml");

Please Sign in or register to post replies

Write your reply to:

Draft