This documentation is archived and is not being maintained.

UIHintAttribute.UIHint Property

Gets or sets the name of the field template to use to display the data field.

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

public string UIHint { get; private set; }

Property Value

Type: System.String
The name of the field template that displays the data field.

ASP.NET Dynamic Data provides field templates and page templates for rendering data fields in a data model. Field templates are user controls (.ascx files) that are mapped to data fields in the model. You can modify the default user controls Dynamic Data provides or create a custom user controls. If you create a custom user control, you use the UIHint property to render the custom user controls. The UIHint property specifies what field template to use when a specific column is rendered. The UIHint property can point to one of the templates provided in Dynamic Data or to a custom template. For example, you can create RedText_Edit.ascx, a custom field template and use the UIHint property to specify that the "RedText_Edit.ascx" custom user control be used to render a specified data field in stead of the default Text_Edit provided in Dynamic Data.

The following code snippet specifies that the ProductName column in a database will be rendered by using a field template named RedText when the item is in edit mode. At run time, Dynamic Data will search for a user control named RedText_Edit.ascx and use it to render the column when the column is in edit mode.

  <asp:DynamicControl runat="server"
    DataField="ProductName" />

Windows 7, Windows Vista, Windows XP SP2, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5 SP1