开发者

partial view rendering

I have a partial view in my Foo folder. I want to show it on m开发者_JAVA技巧y Home/index view. I am using partial render and it is trying to locate it in temp folder. How to write Renderpartial to render foo\partial view ?

regards, Asif hameed


To get it to render just specify the path in RenderPartial like this:

<%Html.RenderPartial("~/Areas/FooArea/Views/Foo.ascx");%>

Obviously replace my example path with the path to your actual Foo partial view.


If you want to call an action that returns a partial view on another controller (foo) try using Html.RenderAction. It will allow you to pass in an action and a controller.

This post has a decent description of the differences between RenderPartial/RenderAction and when to use each one: http://www.arrangeactassert.com/when-to-use-html-renderpartial-and-html-renderaction-in-asp-net-mvc-razor-views/

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜