Ben Aston
Ben Aston

Reputation: 55729

The relationship between view models in master pages, views and partial views in ASP.NET MVC

I have just finished a technical interview. The interviewer asked a question about the relationship between the models associated with a master page, view and partial view, given that the view uses the master and the view contains the partial.

I did not understand what he was driving at. As far as I understood it, view models are supplied by the programmer, meaning the relationship is completely flexible. Can anyone help me out here? I suspect my understanding is lacking, but I may have completely misunderstood the question.

Upvotes: 1

Views: 246

Answers (1)

Gregoire
Gregoire

Reputation: 24832

The master page viewmodel must be a parent class or the same type of the view model.

The partialview viewmodel can be the same type or a property of the view viewmodel or anything else constructed from this viewmodel.

Upvotes: 2

Related Questions