Html.RenderPartial("~/Views/Payments/MyControl.ascx");如果 MyControl.ascx 是直接继承的控件,则从视图调用有效System.Web.Mvc.ViewUserControl。
但是,如果控件继承了派生自 的新类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 助手?