Should strongly typed partial views on one page in asp.net mvc-2 have one combined view model?
- by Kai
Hi guys,
I have a question about asp.net mvc-2 strongly typed partial views, and view models.
I was just wondering if I can (or should) have two strongly typed partial views on one page, without implementing a whole new view model for that page.
For example, I have a page that displays profiles, but also has an inline form to add a quick contact. Each of these entities already has it's own view model, i.e I have a ProfileViewModel and a ContactViewModel.
So my view needs two strongly typed partial views, one using an IEnumerable List of ProfileViewModels, and one using a ContactViewModel. Is it possible or desirable to avoid making a third view model, an 'IndexViewModel' for this page, which holds a list of ProfileViewModels and a ContactViewModel? Is not implementing this view model bad practice, or tidier as it results in less view models?
Thanks!