views:

34

answers:

1

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 < Something.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?

+1  A: 

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>" %>
Graham Miller
well it is like that actually I shortened it.
hrrrr
@hrrrr In your question the control page is inheriting from ViewPage not ViewUserControl
Graham Miller