I have an ASP.NET MVC application which I want to dynamically pick the partial view and what data gets passed to it, while maintaining strong types.
So, in the main form, I want a class that has a view model that contains a generically typed property which should contain the data for the partial view's view model.
public class MainViewModel<T>
{
public T PartialViewsViewModel { get; set; }
}
In the User Control, I would like something like:
Inherits="System.Web.Mvc.ViewUserControl<MainViewModel<ParticularViewModel>>" %>
Though in my parent form, I must put
Inherits="System.Web.Mvc.ViewPage<MainViewModel<ParticularViewModel>>" %>
for it to work.
Is there a way to work around this? The use case is to make the user control pluggable. I understand that I could inherit a base class, but that would put me back to having something like a dictionary instead of a typed view model.