Data Annotations in ASP.NET MVC

What is Data Annotations?

Data Annotations is nothing, it is an inbuilt library in .Net Framework. It is available namespace “System.ComponentModel.DataAnnotations” and it’s contains validation attributes to perform validation rules and also support client and server side validation.

Advantage

It is using the Data Annotation validators in that they enable you to perform validation simply by adding one or more attributes such a the Required or StringLength attribute to a class property.

Data Annotations Attributes

  • DataType
  • DisplayName
  • DisplayFormat
  • Required
  • ReqularExpression
  • Range
  • StringLength
  • MaxLength
  • Bind
  • ScaffoldColumn
Thanks you my blog readers!