开发者

strongly typed class in my ViewUserControl not working?

开发者 https://www.devze.com 2022-12-14 15:26 出处:网络
I am getting an error in my viewuser control: Could not load type \'System.Web.Mvc.ViewUserControl\' My viewpage passes the MyViewUserContr开发者_如何学PythonollerUserList class in the RenderPartial

I am getting an error in my viewuser control:

Could not load type 'System.Web.Mvc.ViewUserControl'

My viewpage passes the MyViewUserContr开发者_如何学PythonollerUserList class in the RenderPartial call.

So I am doing:

  1. action creates its strongly typed view data, which has a property which is a strongly typed class that my userlist.ascx expects.

userlist.ascx:

Inherits="System.Web.Mvc.ViewUserControl<MyViewUserControllerUserList>"

Am I doing this correctly?

Update

Just to make sure, my code for my strongly typed partial user control is:

 public class MyViewUserControllerUserList: ViewUserControl 
{

}


The syntax you have looks correct, however you need to make sure the namespace is incuded as well.

Inherits="System.Web.Mvc.ViewUserControl<My.Class.Namespace.ModelClass>"

Then you would pass it in like this

<% Html.RenderPartial("PartialName", InstanceOfModelClass); %>

Then access it inside the partial using the Model property.

0

精彩评论

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