0

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 Answer 1

1

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>" %>
Sign up to request clarification or add additional context in comments.

2 Comments

well it is like that actually I shortened it.
@hrrrr In your question the control page is inheriting from ViewPage not ViewUserControl

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.