ASP.NET MVC 3 Partial View in layout page

后端 未结 4 716
情歌与酒
情歌与酒 2021-01-04 11:53

I\'m working on setting up a shared content (navigation) for an asp.net MVC layout page.

Here is my partial view \"_LayoutPartial.cshtml\" with code to pull navigati

4条回答
  •  太阳男子
    2021-01-04 12:02

    First verify that your child view is inside the Shared directory

    @Html.Partial("_LayoutPartial")
    

    OR

     @{Html.RenderAction("actionname", "controller name");}
    

    And don't use @Html.Encode(), Razor is already doing for u. Just use

    @item.Name 
    @item.URL
    

提交回复
热议问题