从RAZOR不同的文件夹的RenderPartial [英] RenderPartial from different folder in RAZOR
问题描述
我一直在尝试转换我的aspx页面CSHTML,并用从另一个文件夹呈现部分页面的问题。
I've been trying to convert my aspx pages to cshtml and having an issue with rendering partial pages from another folder.
我以前做:
<% Html.RenderPartial("~/Views/Inquiry/InquiryList.ascx", Model.InquiryList.OrderBy("InquiryId", MvcContrib.Sorting.SortDirection.Descending));%>
我会认为相当于将是:
I would think that the equivalent would be:
@Html.RenderPartial("~/Views/Inquiry/_InquiryList.cshtml", Model.InquiryList.OrderBy("InquiryId", MvcContrib.Sorting.SortDirection.Descending))
这显然是不工作时,我收到以下错误。
This is obviously not working, I am getting the following error.
CS1973:
System.Web.Mvc.HtmlHelper
有一个名为没有适用的方法
部分,但似乎有一个
由该扩展名的方法。
扩展方法不能
动态调度。考虑
铸造动态参数或
无需调用扩展方法
扩展方法的语法。
CS1973: 'System.Web.Mvc.HtmlHelper' has no applicable method named 'Partial' but appears to have an extension method by that name. Extension methods cannot be dynamically dispatched. Consider casting the dynamic arguments or calling the extension method without the extension method syntax.
我怎么会用剃刀视图引擎实现这一目标?
How would I achieve this with using the Razor view engine?
推荐答案
的<一个href=\"http://msdn.microsoft.com/en-us/library/system.web.mvc.html.renderpartialextensions.renderpartial%28VS.98%29.aspx\">RenderPartial不返回一个字符串或IHtmlString值。但是,在响应调用write不渲染。
The RenderPartial does not return a string or IHtmlString value. But does the rendering by calling Write in the Response.
您可以使用部分扩展这个回报一个MvcHtmlString
You could use the Partial extension, this returns an MvcHtmlString
@Html.Partial( ....
或
@{ Html.RenderPartial(....); }
如果你真的想要的RenderPartial
If you really want RenderPartial
这篇关于从RAZOR不同的文件夹的RenderPartial的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!