[Expand]General Information
[Expand]WinForms Controls
[Collapse]ASP.NET Controls and MVC Extensions
 [Expand]Prerequisites
 [Expand]What's Installed
 [Collapse]Common Concepts
  [Expand]Web.config Modifications
  [Expand]Callback Exception Handling
  [Expand]Client-Side Functionality
  [Expand]Cookies Support
  [Expand]Appearance Customization - Theming
   Icon Collection
  [Expand]Performance Optimization
  [Expand]CSS Image Sprites
   Data Annotation Attributes
   Supported Document Types
  [Expand]Accessibility Support
   Right to Left Support
   HTML Encoding
  [Expand]SharePoint Support
   Mobile Support
  [Expand]Office Document Management
   Cloud Storage Account Management
  [Expand]Web Farm and Web Garden Support
 [Expand]ASP.NET WebForms Controls
 [Expand]ASP.NET MVC Extensions
 [Expand]Localization
 [Expand]Redistribution and Deployment
  Get More Help
 [Expand]API Reference
[Expand]ASP.NET Bootstrap Controls
[Expand]ASP.NET Core Bootstrap Controls
[Expand]WPF Controls
[Expand]Xamarin Controls
[Expand]Windows 10 App Controls
[Expand]Office File API
[Expand]Reporting
[Expand]Report and Dashboard Server
[Expand]Dashboard
[Expand]eXpressApp Framework
[Expand]eXpress Persistent Objects
[Expand]CodeRush
[Expand]CodeRush Classic
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation
View this topic on docs.devexpress.com (Learn more)

Data Annotation Attributes

DevExpress ASP.NET and MVC components support data annotation attributes. You can apply these attributes to classes to specify validation rules, data display mode, set relationships between classes, etc.

Expanded Declaration

MVC

Model:

View:

See also: Binding Data Editors to Data

WebForms

Note

For DevExpress ASP.NET WebForms control, only the ASPxFormLayout control supports data annotation attributes if you bind the form layout editors to properties with data attributes.

Model:

Expanded Data Display Attributes

The tables below list the most common data attributes supported by the DevExpress data controls.

Attribute

Description

Example

DisplayAttribute

Specifies localizable strings for classes and members.

DisplayColumnAttribute

Specifies the column that the control displays in the table as a foreign-key column.

CheckBoxValuesAttribute (see CheckBoxValuesAttribute)

Specifies the check box's value.

DisplayFormatAttribute

Specifies a data field's display format.

EditableAttribute

Specifies whether you can edit a data field.

KeyAttribute

Indicates that a property or a field is a key.

MaxLengthAttribute

Specifies a property value's maximum length.

MinLengthAttribute

Specifies a property value's minimum length.

PhoneAttribute

Specifies that a data field value is a phone number.

RegularExpressionAttribute

Specifies that a data field value should match the specified regular expression.

UIHintAttribute

Specifies a template or user control to display a data field.

Expanded Data Type Attributes

Attribute

Description

Example

BindableTypeAttribute

Specifies whether it is a bindable type.

DataTypeAttribute

Specifies the type of data field's value.

EnumDataAttribute

Allows you to replace numeric enumerator values with corresponding declarations.

MetadataTypeAttribute

Allows you to get data annotation attributes from the specified class.

ScaffoldColumnAttribute

Specifies whether a class or data column is hidden.

ScaffoldTableAttribute

Specifies whether a class or data table is hidden.

TimestampAttribute

Specifies a column's data type as a row version.

Expanded Validation Attributes

Attribute

Description

Example

CompareAttribute

Compares the editor's value with another property.

ConcurrencyCheck

Checks a property for optimistic concurrency.

HtmlSettingsAttribute (see HtmlSettingsAttribute)

Note

The HtmlSettingsAttribute class is in effect only for DevExpress ASP.NET MVC extensions.

Specifies the HTML editing settings for the data field value.

CreditCardAttribute

Validates a field value as a credit card number.

CheckBoxRequiredAttribute (see CheckBoxRequiredAttribute)

Specifies that a check box is required.

CustomValidationAttribute

Specifies a custom validation method.

EmailAddressAttribute

Validates a field value as an email address.

FileExtensionsAttribute

Validates file name extensions.

DateRangeAttribute (see DateRangeAttribute)

Note

The DateRangeAttribute class is in effect only for DevExpress ASP.NET MVC extensions.

Specifies the date range settings.

MaskAttribute (see MaskAttribute)

Note

The MaskAttribute class is in effect only for DevExpress ASP.NET MVC extensions.

Specifies the mask settings.

RangeAttribute

Specifies the numeric range constraints for the data field value.

StringLengthAttribute

Specifies the allowed minimum and maximum length of characters in a data field.

RequiredAttribute

Specifies that a data field value is required.

UrlAttribute

Provides URL validation.

Is this topic helpful?​​​​​​​