ThemeableAttribute(Boolean) 建構函式

定義

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

public:
 ThemeableAttribute(bool themeable);
public ThemeableAttribute (bool themeable);
new System.Web.UI.ThemeableAttribute : bool -> System.Web.UI.ThemeableAttribute
Public Sub New (themeable As Boolean)

參數

themeable
Boolean

true 表示初始化 ThemeableAttribute 來代表受主題影響的型別或成員,否則為 false

範例

下列程式碼範例示範如何將 屬性套用 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

備註

true傳遞至這個建構函式相當於使用 Yes 欄位,而傳遞 false 相當於使用 No 欄位。

適用於