开发者

partial view rendering

开发者 https://www.devze.com 2023-02-13 04:56 出处:网络
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 re

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

精彩评论

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