ThemeableAttribute 類別

定義

定義中繼資料屬性,此屬性是 Web 伺服器控制項及其成員用來指示,其呈現是否受主題和控制面板影響。 此類別無法獲得繼承。

public ref class ThemeableAttribute sealed : Attribute
[System.AttributeUsage(System.AttributeTargets.Class | System.AttributeTargets.Property)]
public sealed class ThemeableAttribute : Attribute
[<System.AttributeUsage(System.AttributeTargets.Class | System.AttributeTargets.Property)>]
type ThemeableAttribute = class
    inherit Attribute
Public NotInheritable Class ThemeableAttribute
Inherits Attribute
繼承
ThemeableAttribute
屬性

範例

下列程式碼範例示範如何將 屬性套用 ThemeableAttribute 至 控制項的成員。 在此範例中, ThemeableAttribute 會套用至資料繫結控制項,並 false 傳遞至 ThemeableAttribute 建構函式,表示 DataSourceID 成員無法套用主題。 (傳遞 false 至建構函式會導致 ThemeableAttribute 實例相當於 No field.)

namespace Samples.AspNet.CS.Controls {
    using System;
    using System.Web.UI;
    using System.Web.UI.WebControls;

    public class SomeDataBoundControl : DataBoundControl
    {
        // Implementation of a custom data source control.
        
        [Themeable(false) ]
        [IDReferenceProperty()]
        public override string DataSourceID {
            get {
                return base.DataSourceID;
            }
            set {
                base.DataSourceID = value;
            }
        }
    }
}
Imports System.Web.UI
Imports System.Web.UI.WebControls

Public Class SomeDataBoundControl
    Inherits DataBoundControl

    ' Implementation of a custom data source control.
    
    <Themeable(False)> _
    <IDReferenceProperty()>  _
    Public Overrides Property DataSourceID() As String 
        Get
            Return MyBase.DataSourceID
        End Get
        Set
            MyBase.DataSourceID = value
        End Set
    End Property
    
End Class

備註

控制項開發人員會 ThemeableAttribute 使用 屬性來裝飾控制項類型及其成員,以發出哪些控制項可以和無法受到主題和控制項面板影響。 根據預設,控制項公開的所有屬性都是可主題的。 不過,主題通常只會套用至文體屬性;屬性 Themeable(false) 應該明確套用至所有非文體屬性。 使用 Themeable(false) 屬性裝飾成員可確保成員不會設定主題,而不論 屬性的值 EnableTheming 為何。 例如,如果 ThemeableAttribute 屬性套用至控制項並設定為 false ,即使其 EnableTheming 屬性設定為 true ,控制項也不會受到主題的影響。

類別 ThemeableAttribute 會維護所有支援主題之類型的靜態清單,而且每當呼叫靜態方法和 IsObjectThemeableIsTypeThemeable 時,就會查閱此清單。

建構函式

ThemeableAttribute(Boolean)

初始化 ThemeableAttribute 類別的新執行個體,並使用指定的布林值判斷屬性表示的型別或成員是否會受主題和控制面板影響。

欄位

Default

取得 ThemeableAttribute 執行個體,表示應用程式定義的屬性預設值。

No

取得 ThemeableAttribute 執行個體,用來裝飾不受主題和控制面板影響的型別或成員。

Yes

取得 ThemeableAttribute 執行個體,用來裝飾受主題和控制面板影響的型別或成員。

屬性

Themeable

取得值,指出目前控制項或控制項成員是否受 Web 應用程式定義的主題和控制面板影響。

TypeId

在衍生類別中實作時,取得這個 Attribute 的唯一識別碼。

(繼承來源 Attribute)

方法

Equals(Object)

傳回值,這個值指出此執行個體是否與指定的物件相等。

GetHashCode()

做為 ThemeableAttribute 型別的雜湊函式。

GetType()

取得目前執行個體的 Type

(繼承來源 Object)
IsDefaultAttribute()

取得值,指出目前的執行個體是否等於 Default 類別的 ThemeableAttribute 執行個體。

IsObjectThemeable(Object)

傳回數值,指出傳遞至方法的物件是否支援主題。

IsTypeThemeable(Type)

傳回數值,指出傳遞至方法的 Type 是否支援主題。

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)

適用於

另請參閱