DataTypeAttribute DataTypeAttribute DataTypeAttribute DataTypeAttribute Constructors

Definition

Overloads

DataTypeAttribute(DataType) DataTypeAttribute(DataType) DataTypeAttribute(DataType)

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

DataTypeAttribute(String) DataTypeAttribute(String) DataTypeAttribute(String) DataTypeAttribute(String)

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

DataTypeAttribute(DataType) DataTypeAttribute(DataType) DataTypeAttribute(DataType)

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

public:
 DataTypeAttribute(System::ComponentModel::DataAnnotations::DataType dataType);
public DataTypeAttribute (System.ComponentModel.DataAnnotations.DataType dataType);
new System.ComponentModel.DataAnnotations.DataTypeAttribute : System.ComponentModel.DataAnnotations.DataType -> System.ComponentModel.DataAnnotations.DataTypeAttribute

Parameters

dataType
DataType DataType DataType DataType

The name of the type to associate with the data field.

Examples

The following example shows how to use the DataTypeAttribute(DataType) constructor to specify an alternative type for a data field.

// Add type information.
[DataType(DataType.EmailAddress)]
public object EmailAddress;
' Add type information.
<DataType(DataType.EmailAddress)> _
Public EmailAddress As Object

Remarks

The name is one of the values that are defined by the System.ComponentModel.DataAnnotations.DataType enumeration.

DataTypeAttribute(String) DataTypeAttribute(String) DataTypeAttribute(String) DataTypeAttribute(String)

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

public:
 DataTypeAttribute(System::String ^ customDataType);
public DataTypeAttribute (string customDataType);
new System.ComponentModel.DataAnnotations.DataTypeAttribute : string -> System.ComponentModel.DataAnnotations.DataTypeAttribute
Public Sub New (customDataType As String)

Parameters

customDataType
String String String String

The name of the custom field template to associate with the data field.

Exceptions

customDataType is null or an empty string ("").

Remarks

This method provides an alternative to using the UIHintAttribute attribute.

Applies to