I’m getting this troublesome error in my view:
The model item passed into the dictionary is of type ‘ContactWeb.Models.ContactListViewModel’, but this dictionary requires a model item of type ‘ContactWebLibrary.Contact’.
on this line of code: @{Html.RenderPartial("Form");}
I’m using @model ContactWeb.Models.ContactListViewModel at the top of this file.
Here’s my view:
@model ContactWeb.Models.ContactListViewModel
<h2>Edit</h2>
@{Html.RenderPartial("Form");}
@using (Html.BeginForm())
{
<fieldset>
<legend>Select roles for this user:</legend>
<ul>
@foreach(var role in Model.AllRoles)
{
<li><input name="Roles" type="checkbox" value="@role" />@role</li>
}
</ul>
<input type="submit" />
</fieldset>
}
The error tells you have to pass the right model to the Partial View.
Because you didn’t pass anything, the MVC framework uses the default model which is the view which called to the Partial model.
This will solve things out:
It has nothing to do with
RenderPartialVSPartial.