DataTypeAttribute Konstruktory

Definicja

Inicjuje nowe wystąpienie klasy DataTypeAttribute.

Przeciążenia

DataTypeAttribute(DataType)

Inicjuje DataTypeAttribute nowe wystąpienie klasy przy użyciu określonej nazwy typu.

DataTypeAttribute(String)

Inicjuje DataTypeAttribute nowe wystąpienie klasy przy użyciu określonej nazwy szablonu pola.

DataTypeAttribute(DataType)

Źródło:
DataTypeAttribute.cs
Źródło:
DataTypeAttribute.cs
Źródło:
DataTypeAttribute.cs

Inicjuje DataTypeAttribute nowe wystąpienie klasy przy użyciu określonej nazwy typu.

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)

Parametry

dataType
DataType

Nazwa typu, który ma być skojarzony z polem danych.

Przykłady

W poniższym przykładzie pokazano, jak za pomocą konstruktora DataTypeAttribute(DataType) określić alternatywny typ pola danych.

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

Uwagi

Nazwa jest jedną z wartości zdefiniowanych przez System.ComponentModel.DataAnnotations.DataType wyliczenie.

Dotyczy

DataTypeAttribute(String)

Źródło:
DataTypeAttribute.cs
Źródło:
DataTypeAttribute.cs
Źródło:
DataTypeAttribute.cs

Inicjuje DataTypeAttribute nowe wystąpienie klasy przy użyciu określonej nazwy szablonu pola.

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)

Parametry

customDataType
String

Nazwa szablonu pola niestandardowego do skojarzenia z polem danych.

Wyjątki

customDataType jest null lub pusty ciąg ("").

Uwagi

Ta metoda stanowi alternatywę dla używania atrybutu UIHintAttribute .

Dotyczy