ASP.NET equivalent of server side includes

前端 未结 4 845
离开以前
离开以前 2020-11-30 03:13

Although the classic ASP method of server-side includes works in ASP.NET, I get the impression it is not the preferred method. How am I \"supposed\" to be achieving the same

4条回答
  •  佛祖请我去吃肉
    2020-11-30 03:58

    If you'e using ASP.NET MVC then Html.RenderPartial is your friend here.

    http://msdn.microsoft.com/en-us/library/system.web.mvc.html.renderpartialextensions.renderpartial.aspx

    A partial view can be implemented as a .ascx or an .aspx and putting the above call in your "primary" page basically says "get the output from this partial view and render it here".

    Parial views can make use of the ViewData that your primary view received from the controller.

提交回复
热议问题