I have two views: a partial view, and a view that encapsulates the partial view using @Html.RenderPartial("_PartialView")
. Each has its own ViewModel:
public class PartialViewModel
{
// properties, etc.
}
public class MainViewModel
{
public PartialViewModel p { get; set; }
// properties, etc.
}
I'm getting dictionary errors when I load up the second view (the one that uses MainViewModel), because this view and the partial view it encapsulates are using two different ViewModels. I can't have them use the same ViewModel, because the partial view is rendered inside many other different views.
To be clear, both of these views contain forms, with the partial view representing all of the shared fields between forms. Given this, do I have any options, or am I simply attempting to do something that does not fit within the MVC design constraints?