Rendering a derived partial view with Html.RenderPartial
Posted
by FreshCode
on Stack Overflow
See other posts from Stack Overflow
or by FreshCode
Published on 2010-03-18T18:41:40Z
Indexed on
2010/03/18
18:51 UTC
Read the original article
Hit count: 541
Calling Html.RenderPartial("~/Views/Payments/MyControl.ascx");
from a view works if Method.ascx is a control that directly inherits System.Web.Mvc.ViewUserControl
.
However, if the control inherits a new class that derives from System.Web.Mvc.ViewUserControl
, the call to Html.RenderPartial("~/Views/Payments/MyDerivedControl.ascx");
fails, reporting that no such view exists.
Example derived ViewUserControl:
class MyDerivedControl : System.Web.Mvc.ViewUserControl
{
public Method()
{
ViewData["SomeData"] = "test";
}
}
Is there a workaround, or is there another way I should be doing this? Perhaps an HTML helper?
© Stack Overflow or respective owner