Data annotation of Asp.net MVC 4 Model

Source: Internet
Author: User

[Bind (…)]

Lists fields to exclude or include when binding parameter or form values to model properties

When listing fields, exclude or include binding parameters or form model attribute values

[Compare ("... ")]

To compare two properties.

Compare two attributes.

[CreditCard]

To Specify that a data field value is a credit card number.

The value of a data field is a credit card number.

[DataType (DataType. <type>)]

Used for formatting purposes, not for validation.

It is used for format purposes rather than for verification.

[DisplayName (…)]

Defines the text we want used on form fields and validation messages

Form fields and verification messages that we want to define on the text

[EmailAddress]

To validate an email address

To verify an email address

[FileExtensions (Extensions = "jpg, png... ")]

To Validate file name extensions.

To verify file name extension.

[Key]

To denote one or more properties that uniquely identify an entity.

Uniquely identifies an object to indicate one or more attributes.

[MaxLength (…)]

To define the maximum length of array or string data allowed in a property.

The maximum length allowed in the attribute of the array or string data to be defined.

[MinLength (…)]

To define the minimum length of array of string data allowed in a property.

Minimum length allowed in the attribute of the array or string data to be defined.

[Phone ..]

To Specify for phone number using a regular expression.

The specified phone number, which uses a regular expression.

[Range (…)]

Gives a maximum and minimum value for a numeric field

The maximum and minimum values of a numeric field are given.

[RegularExpression (…)]

To specify that a data field value must match the specified regular expression.

To specify the value of a data field, you must use the specified regular expression.

[Required (…)]

Indicates that the property is a required field

This attribute is required.

[StringLength (…)]

Defines a maximum length for a string field

Defines the maximum length of a string field

[ScaffoldColumn (…)]

Allows hiding fields from editor forms

Allow hidden fields from the editor form

[Url]

It provides URL validation.

It provides URL Verification

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.