Two models in one view in ASP MVC 3

后端 未结 12 1889
日久生厌
日久生厌 2020-11-22 13:55

I have 2 models:

public class Person
{
    public int PersonID { get; set; }
    public string PersonName { get; set; }
}
public class Order
{
    public int         


        
12条回答
  •  感情败类
    2020-11-22 14:34

    Beside of one view model in asp.net you can also make multiple partial views and assign different model view to every view, for example:

       @{
            Layout = null;
        }
    
        @model Person;
    
        
        
    

    then another partial view Model for order model

        @{
            Layout = null;
         }
    
        @model Order;
    
        
        
    

    then in your main view load both partial view by

    
    
    

提交回复
热议问题