Reputation: 4277
I am doing testing of a form, it has many fields. I want to set the value of the fields so I do not have to keep re-entering it. Is there a way to set it in the class metadata area, where I also set it as Required type.
[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; }
Upvotes: 1
Views: 964
Reputation: 14302
Use DefaultValue attribute for this.
[Required]
[Display(Name = "City")]
[DefaultValue("London")]
public string City { get; set; }
This will resolve your concern.
Upvotes: 1