passing parameters to my partial view?

前端 未结 4 1253
醉酒成梦
醉酒成梦 2020-12-29 19:55

I am calling my partial view like this:

 <% Html.RenderPartial(\"~/controls/users.ascx\"); %>

Can I pass parameters to partial view?

4条回答
  •  情话喂你
    2020-12-29 20:19

    There is another overload for RenderPartial that will pass your model through.

    <% Html.RenderPartial("~/controls/users.ascx", modelGoesHere); %>
    

    How to access? Just like you normally would with any view:

    <%= Model.MagicSauce %>
    

提交回复
热议问题