Asp.net MVC Html.Renderpartial Problem
Well I have this page
< %@ .............. Inherits="System.Web.Mvc.ViewPage < Something.Models.SomeModel >" %>
< % Html.RenderPartial("SomeControl",Model);% >
and this user control page
< %@ Control Language="C#" Inherits="System.Web.Mvc.ViewPage < Somet开发者_JAVA百科hing.Models.SomeModel>"%>
< p>< %: Html.TextBox("text",Model.Name) %>< /p>
and I get this exception
Cannot covert type 'ASP.views_somecontrol_ascx' to 'System.Web.Mvc.ViewUserControl'
Any idea about why this is happenig?
Your user control page should inherit from System.Web.Mvc.ViewUserControl<TModel>
not System.Web.Mvc.ViewPage<TModel>
.
On your user control page use:
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<Something.Models.SomeModel>" %>
精彩评论