UIHintAttribute 類別

定義

指定 Dynamic Data 用來顯示資料欄位的範本或使用者控制項。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)

將一組名稱對應至一組對應的分派識別項 (Dispatch Identifier)。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)

適用於

另請參閱