UIHintAttribute.UIHint Property

Definition

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

public:
 property System::String ^ UIHint { System::String ^ get(); };
public string UIHint { get; }
member this.UIHint : string
Public ReadOnly Property UIHint As String

Property Value

The name of the field template that displays the data field.

Remarks

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 that Dynamic Data provides, or you can create a custom user controls to use as field template. If you create a custom user control, you use the UIHint property on a property so that the property is rendered using the custom user control. The UIHint property specifies which 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 a custom field template named RedText_Edit.ascx, and then use the UIHint property to specify that the RedText_Edit.ascx control should be used to render a specified data field instead of the default Text_Edit.ascx template that is provided in Dynamic Data.

The following example shows how to specify that the UnitsInStock column in a database will be rendered by using the specified custom field template.

using System;
using System.Web.DynamicData;
using System.ComponentModel.DataAnnotations;

[MetadataType(typeof(ProductMetadata))]
public partial class Product 
{
}

public partial class ProductMetadata
{
    [UIHint("UnitsInStock")]
    [Range(100, 10000, 
    ErrorMessage = "Units in stock should be between {1} and {2}.")]
    public object UnitsInStock;
}
Imports System.Web.DynamicData
Imports System.ComponentModel.DataAnnotations


<MetadataType(GetType(ProductMetadata))> _
Partial Public Class Product

End Class

Partial Public Class ProductMetadata
    <UIHint("UnitsInStock")> _
    <Range(100, 10000)> _
    Public UnitsInStock As Object
End Class

Applies to

See also