ASP.NET MVC2, How to Add Metadata Attributes and Control the order of properties displayed in the View
In ASP.NET MVC2, I have two ViewModels with Parent-Child relationship as below.
Parent ViewModel:
public class PersonViewModel
{
[Required]
public int ID{get;set;}
[Required]
开发者_Go百科 [StringLength(50)]
public string Name{get;set;}
}
Child ViewModel:
public class EmployeeViewModel:PersonViewModel
{
[Required]
[StringLength(50)]
public string Title{get;set;}
}
I have two questions with this setting.
How can I add Metadata Attributes to the properties in the parent ViewModel from the child ViewModel?
When displayed in the View using Html.DisplayForModel(), It seems the properties in the parent ViewModel always display after those of the child ViewModel. how can I control the order of properties displayed?
精彩评论