UIHintAttribute 类

定义

指定动态数据用来显示数据字段的模板或用户控件。

public ref class UIHintAttribute : Attribute
[System.AttributeUsage(System.AttributeTargets.Field | System.AttributeTargets.Property, AllowMultiple=true)]
public class UIHintAttribute : Attribute
[<System.AttributeUsage(System.AttributeTargets.Field | System.AttributeTargets.Property, AllowMultiple=true)>]
type UIHintAttribute = class
    inherit Attribute
Public Class UIHintAttribute
Inherits Attribute
继承
UIHintAttribute
属性

示例

以下示例演示如何使用 UIHintAttribute 特性指定用于处理数据字段的显示和编辑的自定义字段模板的名称。

有关完整示例,请参阅 如何:在数据模型中自定义数据字段显示

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

注解

MVC 使用 UIHintAttribute 类将模型与数据字段关联。 动态数据使用 UIHintAttribute 类将用户控件与数据字段相关联。 动态数据使用 UIHint 属性来确定要用于显示数据字段的用户控件。

有关如何使用属性的详细信息,请参阅 “属性”。

构造函数

UIHintAttribute(String)

使用指定的用户控件初始化 UIHintAttribute 类的新实例。

UIHintAttribute(String, String)

使用指定的用户控件和指定的表示层初始化 UIHintAttribute 类的新实例。

UIHintAttribute(String, String, Object[])

使用指定的用户控件、表示层和控件参数初始化 UIHintAttribute 类的新实例。

属性

ControlParameters

获取或设置将用于从任何数据源中检索值的 DynamicControlParameter 对象。

PresentationLayer

获取或设置使用 UIHintAttribute 类的表示层。

TypeId

获取特性的唯一标识符。

TypeId

在派生类中实现时,获取此 Attribute 的唯一标识符。

(继承自 Attribute)
UIHint

获取或设置要用于显示数据字段的字段模板的名称。

方法

Equals(Object)

获取一个值,该值指示此实例是否与指定的对象相等。

Equals(Object)

返回一个值,该值指示此实例是否与指定的对象相等。

(继承自 Attribute)
GetHashCode()

获取特性的当前实例的哈希代码。

GetHashCode()

返回此实例的哈希代码。

(继承自 Attribute)
GetType()

获取当前实例的 Type

(继承自 Object)
IsDefaultAttribute()

在派生类中重写时,指示此实例的值是否是派生类的默认值。

(继承自 Attribute)
Match(Object)

当在派生类中重写时,返回一个指示此实例是否等于指定对象的值。

(继承自 Attribute)
MemberwiseClone()

创建当前 Object 的浅表副本。

(继承自 Object)
ToString()

返回表示当前对象的字符串。

(继承自 Object)

显式接口实现

_Attribute.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr)

将一组名称映射为对应的一组调度标识符。

(继承自 Attribute)
_Attribute.GetTypeInfo(UInt32, UInt32, IntPtr)

检索对象的类型信息,然后可以使用该信息获取接口的类型信息。

(继承自 Attribute)
_Attribute.GetTypeInfoCount(UInt32)

检索对象提供的类型信息接口的数量(0 或 1)。

(继承自 Attribute)
_Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr)

提供对某一对象公开的属性和方法的访问。

(继承自 Attribute)

适用于

另请参阅