Should strongly typed partial views on one page in asp.net mvc-2 have one combined view model?

Posted by Kai on Stack Overflow See other posts from Stack Overflow or by Kai
Published on 2010-05-25T02:02:43Z Indexed on 2010/05/25 2:11 UTC
Read the original article Hit count: 512

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!

© Stack Overflow or respective owner

Related posts about asp.net-mvc-2

Related posts about viewmodel