Edit

Share via


DataTypeAttribute Constructors

Definition

Initializes a new instance of the DataTypeAttribute class.

Overloads

DataTypeAttribute(DataType)

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

DataTypeAttribute(String)

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

DataTypeAttribute(DataType)

Source:
DataTypeAttribute.cs
Source:
DataTypeAttribute.cs
Source:
DataTypeAttribute.cs

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
Public Sub New (dataType As DataType)

Parameters

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.

Applies to

DataTypeAttribute(String)

Source:
DataTypeAttribute.cs
Source:
DataTypeAttribute.cs
Source:
DataTypeAttribute.cs

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

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