我正在做一個窗體的測試,它有很多領域。我想設置字段的值,所以我不必再重複輸入。有沒有辦法在類元數據區域中設置它,我也將其設置爲必需類型。MVC如何設置值元數據
[MetadataType(typeof(myMetaData))]
public partial class myClass
{
[Required]
[Display(Name = "Zip")]
public string Zip { get; set; }
[Required]
[Display(Name = "State")]
public string State { get; set; }
[Required]
[Display(Name = "City")]
public string City { get; set; }
看看這個:http://stackoverflow.com/questions/7637022/default-value-in-an-asp-net-mvc-view-model – 2013-03-17 02:02:56