UIHintAttribute 類別

定義

指定 Dynamic Data 用來顯示資料欄位的範本或使用者控制項。

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)

將一組名稱對應至一組對應的分派識別項 (Dispatch Identifier)。

(繼承來源 Attribute)
_Attribute.GetTypeInfo(UInt32, UInt32, IntPtr)

擷取物件的類型資訊,可以用來取得介面的類型資訊。

(繼承來源 Attribute)
_Attribute.GetTypeInfoCount(UInt32)

擷取物件提供的類型資訊介面數目 (0 或 1)。

(繼承來源 Attribute)
_Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr)

提供物件所公開的屬性和方法的存取權。

(繼承來源 Attribute)

適用於

另請參閱