Nest Objects in View Model in ASP.Net MVC Core
I started to use ASP.Net Core in our web development. The first challenge I faced is about the nested View Model.
I have not used much in nested view model in the previous of MVC,
I got the View Models like this:
Code
public Order{ | |
public int Id {get;set;} | |
public Customer Customer {get;set;} | |
} | |
| |
public Customer{ | |
public string FirstName {get;set;} | |
public string LastName {get;set;} | |
} |
If I wish to do the binding in the razor html
You have to add the bind in the controller
Code
public async Task add the binding in the Customer class too | |
|
mc_code_odd">[Bind("FirstName,LastName")]
public Customer{
public string FirstName {get;set;}
public string LastName {get;set;}
}
Trackback address for this post
Trackback URL (right click and copy shortcut/link location)
Feedback awaiting moderation
This post has 101 feedbacks awaiting moderation...
Form is loading...