\" %>" />
开发者

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>" %>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜