Data Annotation attributes in MVC3 Razor
2. These attributes provide server - side validation and the framework also supports client-side validation when you use one of the attributes on a model property.
Following are the attributes :
- Required - This attribute makes the property of model mandatory for user.
- StringLength - The StringLength attribute specifies the maximum length of string that is acceptable.
- RegularExpression - Regular expressions are an efficient and terse means to enforce the shape and contents of a string value.
- Range - The Range attribute specified the minimum and maximum constraints for a numerical value.
- Compare - The compare attribute ensures two properties on a model object have the same value.
- Display - The Display attribute sets the friendly name for a model property.
- ScaffoldColumn - The scaffoldColumn attribute hides a property from HTML helper such as EditorForModel and DisplayForModel.
- MaxLength - MaxLength Attribute ensures the length of the string entered is according to the specified value.
- DataType - The DataType attribute enables you to provide the run time with information about the specific purpose of a property.
- UIHint - The UIHint attribute as the name itself suggest gives the Asp.net MVC run time the name of a template to use when rendering output with the templated helpers like (DisplayFor and EditorFor).
- HiddenInput - The property that has HiddenInput defined on it will be rendered as input type hidden on form.
0 comments:
Post a Comment