views:

42

answers:

0

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]
 [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.

  1. How can I add Metadata Attributes to the properties in the parent ViewModel from the child ViewModel?

  2. 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?