Render partial from different folder (not shared)

前端 未结 10 2015
名媛妹妹
名媛妹妹 2020-11-29 17:12

How can I have a view render a partial (user control) from a different folder? With preview 3 I used to call RenderUserControl with the complete path, but whith upgrading to

10条回答
  •  盖世英雄少女心
    2020-11-29 17:40

    Just include the path to the view, with the file extension.

    Razor:

    @Html.Partial("~/Views/AnotherFolder/Messages.cshtml", ViewData.Model.Successes)
    

    ASP.NET engine:

    <% Html.RenderPartial("~/Views/AnotherFolder/Messages.ascx", ViewData.Model.Successes); %>
    

    If that isn't your issue, could you please include your code that used to work with the RenderUserControl?

提交回复
热议问题