UIHintAttribute 类

定义

指定动态数据用来显示数据字段的模板或用户控件。Specifies the template or user control that Dynamic Data uses to display a data field.

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 属性指定将处理数据字段的显示和编辑的自定义字段模板的名称。The following example shows how to use the UIHintAttribute attribute to specify the name of a custom field template that will handle the display and editing of a data field.

有关完整示例,请参阅 如何:自定义数据字段显示在数据模型中For a complete example, see How to: Customize Data Field Display in the Data Model.

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 类将模型与数据字段关联。MVC uses the UIHintAttribute class to associate a model with a data field. 动态数据使用 UIHintAttribute 类将用户控件与数据字段关联。Dynamic Data uses the UIHintAttribute class to associate a user control with a data field. 动态数据使用 UIHint 属性确定要用于显示数据字段的用户控件。Dynamic Data uses the UIHint property to determine which user control to use in order to display a data field.

有关如何使用特性的详细信息,请参阅 特性For more information about how to use attributes, see Attributes.

构造函数

UIHintAttribute(String)

使用指定的用户控件初始化 UIHintAttribute 类的新实例。Initializes a new instance of the UIHintAttribute class by using a specified user control.

UIHintAttribute(String, String)

使用指定的用户控件和指定的表示层初始化 UIHintAttribute 类的新实例。Initializes a new instance of the UIHintAttribute class using the specified user control and specified presentation layer.

UIHintAttribute(String, String, Object[])

使用指定的用户控件、表示层和控件参数初始化 UIHintAttribute 类的新实例。Initializes a new instance of the UIHintAttribute class by using the specified user control, presentation layer, and control parameters.

属性

ControlParameters

获取或设置将用于从任何数据源中检索值的 DynamicControlParameter 对象。Gets or sets the DynamicControlParameter object to use to retrieve values from any data source.

PresentationLayer

获取或设置使用 UIHintAttribute 类的表示层。Gets or sets the presentation layer that uses the UIHintAttribute class.

TypeId

获取特性的唯一标识符。Gets the unique identifier for the attribute.

TypeId

在派生类中实现时,获取此 Attribute 的唯一标识符。When implemented in a derived class, gets a unique identifier for this Attribute.

(继承自 Attribute)
UIHint

获取或设置要用于显示数据字段的字段模板的名称。Gets or sets the name of the field template to use to display the data field.

方法

Equals(Object)

获取一个值,该值指示此实例是否与指定的对象相等。Gets a value that indicates whether this instance is equal to the specified object.

Equals(Object)

返回一个值,该值指示此实例是否与指定的对象相等。Returns a value that indicates whether this instance is equal to a specified object.

(继承自 Attribute)
GetHashCode()

获取特性的当前实例的哈希代码。Gets the hash code for the current instance of the attribute.

GetHashCode()

返回此实例的哈希代码。Returns the hash code for this instance.

(继承自 Attribute)
GetType()

获取当前实例的 TypeGets the Type of the current instance.

(继承自 Object)
IsDefaultAttribute()

在派生类中重写时,指示此实例的值是否是派生类的默认值。When overridden in a derived class, indicates whether the value of this instance is the default value for the derived class.

(继承自 Attribute)
Match(Object)

当在派生类中重写时,返回一个指示此实例是否等于指定对象的值。When overridden in a derived class, returns a value that indicates whether this instance equals a specified object.

(继承自 Attribute)
MemberwiseClone()

创建当前 Object 的浅表副本。Creates a shallow copy of the current Object.

(继承自 Object)
ToString()

返回表示当前对象的字符串。Returns a string that represents the current object.

(继承自 Object)

显式接口实现

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

将一组名称映射为对应的一组调度标识符。Maps a set of names to a corresponding set of dispatch identifiers.

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

检索对象的类型信息,然后可以使用该信息获取接口的类型信息。Retrieves the type information for an object, which can be used to get the type information for an interface.

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

检索对象提供的类型信息接口的数量(0 或 1)。Retrieves the number of type information interfaces that an object provides (either 0 or 1).

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

提供对某一对象公开的属性和方法的访问。Provides access to properties and methods exposed by an object.

(继承自 Attribute)

适用于