Web
Analytics
Data Annotation and Validations in ASP.NET MVC 5 - Tutorial

For Consultation : +91 9887575540

Stay Connected :

Data annotations are used to perform client side and server side validations on a page.

It’s a mechanism, Atrrributeswe can use it to feed metadata into application and framework will display and render HTML markup.
Data Annotations are Attributes which are used to perform server-side validations as well as client side validations.
Data Attributes with Example.
1. Required
[Required]
public string UserName{get;set;}
2. StringLength
StringLength(20)
Public string Name{get;set;}
3. RegularExpression
RegularExpression(“.+@.+\\..+”,ErrorMessage=“Email format is not good”)
public string Email{get;set;}
4. Range
[Range(30,35)
Public int Age{get;set;}
5.Compare
Public string password{get;set;}
[Compare(“Password”,ErrorMessage=“Password and Compare Password should be same”)
Public string ConfirmPassword{get;set;}
For Source code and other tutorial Please visit
www.yogeshdotnet.com

Server Side Validation using Data Annotations

 

 

Download

Sending
User Review
0 (0 votes)
Select your currency