How many types of Data Annotation Attributes in MVC ?

Types of validation in MVC...

Last updated:10/8/2018 5:04:22 AM

1 Answers

Anonymous User
Anonymous User

Data Annotations in Asp.Net MVC

How many types of Data Annotation Attributes in MVC ?

OR

Key [Key]
public int StudentID { get; set; }
DisplayName [DisplayName('StudentName')]
Required [Required(ErrorMessage = 'Enter Student Name')]
DataType [DataType(DataType.Password)]
StringLength [StringLength(50, ErrorMessage = 'Only 50 character are allowed')]
DisplayFormat [DisplayFormat(DataFormatString = '{0:dd.MM.yyyy}')]
Regular Expression [RegularExpression(@'[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,4}', ErrorMessage = 'Please enter Valid Email ID')]
Range [Range(5000, 15000, ErrorMessage = 'Please enter valid range')]
Bind [Bind(Exclude = 'StudentID')]
Compare [DataType(DataType.Password)]
[Required(ErrorMessage = 'Please enter password')]
public string Password { get; set; }

[Required(ErrorMessage = 'Please enter ConfirmPassword')]
[DataType(DataType.Password)]
[Compare('Password', ErrorMessage = 'Password not matching')]
public string ConfirmPassword { get; set; }


Answer