System.ComponentModel.DataAnnotations 4.0.0.0 System.ComponentModel.DataAnnotations.ValidationAttribute System.AttributeUsage(System.AttributeTargets.Method | System.AttributeTargets.Property | System.AttributeTargets.Field | System.AttributeTargets.Parameter | System.AttributeTargets.All, AllowMultiple=false)

The attribute enables you to mark fields by using a type that is more specific than the database intrinsic type. The type name is selected from the enumeration type. For example, a string data field that contains e-mail addresses can be specified as the type. This information is then accessed by the field templates to modify how the data field is processed.

You use the attribute for the following reasons:

To provide additional type information for a data field. You do this by applying the attribute to a data field in the data model and by specifying the additional type name from the enumeration. The field template that processes the data field can access this additional metadata type information to determine how to process the field. For example, the text field template can generate hyperlinks for e-mail addresses whose intrinsic type is String.

To associate a custom field template with a data field. The specified custom field template will then be used to process the data field. This is an alternative to using the attribute.

When you apply the attribute to a data field you must do the following:

Follow the attribute usage rules.

Implement the metadata class that contains the data fields to which you want to apply the attribute.

Issue validation errors as appropriate.

For more information, see ASP.NET Dynamic Data Guidelines.

See a run-time code example of this feature: Run.

Specifies the name of an additional type to associate with a data field.

- Constructor
  4.0.0.0

  The name is one of the values that are defined by the enumeration.

  Initializes a new instance of the class by using the specified type name.

  The name of the type to associate with the data field.
- Constructor
  4.0.0.0

  This method provides an alternative to using the attribute.

  Initializes a new instance of the class by using the specified field template name.

  The name of the custom field template to associate with the data field.
- Property
  4.0.0.0
  System.String To be added. To be added.

  Gets the name of custom field template that is associated with the data field.

- Property
  4.0.0.0
  System.ComponentModel.DataAnnotations.DataType To be added. To be added.

  Gets the type that is associated with the data field.

- Property
  4.0.0.0
  System.ComponentModel.DataAnnotations.DisplayFormatAttribute To be added. To be added.

  Gets a data-field display format.

- Method
  4.0.0.0
  System.String

  The name of the type that is associated with the data field.

  Returns the name of the type that is associated with the data field.

  The name of the type associated with the data field.

- Method
  4.0.0.0
  System.Boolean ``

  This method implements validation logic that is specific to the attribute.

  Checks that the value of the data field is valid.

  true always.

  The data field value to validate.