我试图在acsx文件中使用Html.RenderPartial
我收到一个错误:
我收到一个错误:
Compiler Error Message: CS1973: ‘System.Web.Mvc.HtmlHelper’
has no applicable method named ‘RenderPartial’ 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 @R_403_156@
<a href="/projects/<%=project.Id %>"> <% Html.Label("fdf"); %> <% Html.RenderPartial("ProjectName",Model.Id); %></a></li> <%} %>
但是我已经导入了必需的命名空间,所以它不会出错
<% Html.Label("fdf"); %>
有没有办法在ascx文件中使用Html.RenderPartial?
解决方法
编译器无法选择正确的方法,因为您的模型是动态的。将呼叫更改为:
<% Html.RenderPartial("ProjectName",(int)(Model.Id)); %>
或任何其他数据类型Id。