【发布时间】:2010-03-18 18:41:40
【问题描述】:
如果 MyControl.ascx 是直接继承 System.Web.Mvc.ViewUserControl 的控件,则从视图调用 Html.RenderPartial("~/Views/Payments/MyControl.ascx"); 有效。
但是,如果控件继承派生自System.Web.Mvc.ViewUserControl 的新类,则对Html.RenderPartial("~/Views/Payments/MyDerivedControl.ascx"); 的调用将失败,并报告不存在此类视图。
示例派生System.Web.Mvc.ViewUserControl:
class MyDerivedControl : System.Web.Mvc.ViewUserControl
{
public Method()
{
ViewData["SomeData"] = "test";
}
}
是否有解决方法,或者有其他方法我应该这样做吗?也许是 HTML 助手?
【问题讨论】:
标签: asp.net-mvc partial-views renderpartial viewusercontrol