I am new in MVC3. When i create a strongly typed view it use this code at top on the view code file
@model MonoPoly.Models.LandDocument
so it means that view can use all property from that Model class (here this LandDocument model class). But my question is how can i user more model class as a strongly typed for this single view file ? OR how should i can call other model class property in this view which is already strongly typed with that LandDocument Model class ?
Sorry for my bad English.
One approach is to create a
ViewModelobject that contains all the objects you would like to reference in your view. See the details of how to implement the ViewModel pattern on Steve Michelotti’s blog: Pattern 2 – Dedicated view model that contains the domain model objectFor example, if you wanted both the
LandDocumentclass and aPlayerclass, you could create aViewModellike this:and then at the top of your view:
You would access the data in your view with like this, for example: