views:

243

answers:

1

I am getting an error in my viewuser control:

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

My viewpage passes the MyViewUserControllerUserList 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 
{

}
+1  A: 

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.

Chris Gutierrez
The InstanceOFModelClass is: ViewData.Model. correct?
mrblah
It could be. it could also be a piece of view data that was set in your controller thats not your model. So lets say in your controller you have ViewData["PartialModel"] = SomeObject; then in your master page, you could call <% Html.RenderPartial("PartialName", ViewData["PartialModel"]); %>In short, you can have any object in your view data be the model of a partial. Hope this helps.
Chris Gutierrez
I see ok, I am using strongly typed viewdata in both my model and in the call to my partial. let me investigate arghhh!
mrblah