Export (0) Print
Expand All

DataType Enumeration

Represents data types that are associated with data properties.

Namespace:  System.ComponentModel.DataAnnotations
Assembly:  System.ComponentModel.DataAnnotations (in System.ComponentModel.DataAnnotations.dll)

'Declaration
Public Enumeration DataType

Member nameDescription
CustomRepresents a data type that is not one of the known types.
DateTimeRepresents an instant in time, expressed as a date and time of day.
DateRepresents a data value.
TimeRepresents a time value.
DurationRepresents a continuous time during which an object exists.
PhoneNumberRepresents a phone number value.
CurrencyRepresents a currency value.
TextRepresents text that is displayed.
HtmlRepresents an HTML file.
MultilineTextRepresents multiline text.
EmailAddressRepresents an e-mail address.
PasswordRepresents a password value.
UrlRepresents a URL value.
ImageUrlRepresents a URL value that is displayed as an image instead of text.

You use the DataType enumeration when you apply the DataTypeAttribute attribute to a property. The DataType enumeration contains valid values you use with the DataTypeAttribute attribute. You use the DataTypeAttribute attribute to specify the type of data that is expected for the property beyond the data type of the property. For example, properties named Phone and EmailAddress may both contain string values, but you can specify the expected values by applying the DataTypeAttribute attribute with the PhoneNumber and EmailAddress values respectively.

The following example shows how to specify an e-mail address property and a phone number property.


Public Class Customer
  <DataType(DataType.EmailAddress)> _
  Public Property EmailAddress As String
    'Implement Get and Set logic
  End Property

  <DataType(DataType.PhoneNumber)> _
  Public Property Phone As String
    'Implement Get and Set logic
  End Property
End Class


Silverlight

Supported in: 5, 4, 3

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.

Community Additions

ADD
Show:
© 2014 Microsoft