10 April 2013

Format Display Name and Add Required Validator for Date

Just want to share this short script in formatting the Display Name and in making the entity a required element. 

 [Required(ErrorMessage = "Date Hired is required.")]
 [DisplayFormat(DataFormatString="{0:dd-MM-yyyy}", ApplyFormatInEditMode=true)]
 [DisplayName("Date Hired")]
      
public DateTime DateHired { get; set; }

No comments:

Post a Comment