Posts

Showing posts from February, 2017

data annotation attributes c#

 C# DataAnnotation   Attributes 1.Required 2.StringLengtgh 3.DisplayName 4.Range 5.Compare 6.ScaffoldColumn 7.RegularExpression 8.EmailAddress 9.Url 10.Remote 11.MinLength 12.MaxLength 13.DataType 14. custom dataAnnotation Attribute Required : Ensures that a property has been assigned some value. Range : Ensures that a property value falls within a minimum and maximum value. StringLength : Can be used to check the length of a string property. You can either specify maximum permissible length or maximum and minimum permissible length. EmailAddress : Validates that an email address with a valid email format has been supplied as a property value. Url : Validates that a valid URL has been supplied as a property value. RegularExpression : Uses a regular expression to ensure that a property value matches the specified pattern. Example using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.ComponentModel.DataAnnotation