DataBindingHandlerAttribute 類別

定義

指定設計時間類別,以在設計工具內執行控件的數據系結。 此類別無法獲得繼承。

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

範例

以下程式碼範例定義了一個資料綁定處理器,名為 MyDataBindingHandler,供設計者在編輯模式下使用。 退出編輯模式後, Text 屬性值會顯示出來。


using System;
using System.Collections;
using System.Web.UI;
using System.Web.UI.Design;
using System.Web.UI.WebControls;
using System.ComponentModel;
using System.ComponentModel.Design;

namespace CustomControls
{
  [
    DataBindingHandler(typeof(MyDataBindingHandler)),
    ToolboxData("<{0}:MyLabel runat=server></{0}:MyLabel>")
  ]
  public class MyLabel : Label 
  {
    public  MyLabel()
    { 
      // Insert your code here.
    } 
  }

  public class MyDataBindingHandler : DataBindingHandler
  {
    public override void DataBindControl(IDesignerHost host, Control control)
    {
      ((Label)control).Text = "Added by data binding handler.";
    }
  }
}

Namespace CustomControls

  <DataBindingHandler(GetType(MyDataBindingHandler)), ToolboxData("<{0}:MyLabel runat=server></{0}:MyLabel>")>  _
    Public Class MyLabel
      Inherits Label
      
      Public Sub New()
        'Insert your code here.
      End Sub
      
    End Class
   
    Public Class MyDataBindingHandler
      Inherits DataBindingHandler
      
      Public Overrides Sub DataBindControl(host As IDesignerHost, control As Control)
         CType(control, Label).Text = "Added by data binding handler."
      End Sub
      
    End Class
    
End Namespace 'CustomControls

備註

欲了解更多屬性的使用資訊,請參閱屬性。

建構函式

名稱 Description
DataBindingHandlerAttribute()

初始化一個新的類別實例 DataBindingHandlerAttribute ,使用無參數。 這就是無參數建構子。

DataBindingHandlerAttribute(String)

初始化一個以指定類型名稱的新 DataBindingHandlerAttribute 類別實例。

DataBindingHandlerAttribute(Type)

初始化指定DataBindingHandlerAttribute類別 的新實例Type

欄位

名稱 Description
Default

定義了該 DataBindingHandlerAttribute 類別的預設屬性。

屬性

名稱 Description
HandlerTypeName

取得資料綁定處理器的型別名稱。

TypeId

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

(繼承來源 Attribute)

方法

名稱 Description
Equals(Object)

判斷兩個物件實例是否相等。

Equals(Object)

傳回值,這個值表示這個實例是否等於指定的物件。

(繼承來源 Attribute)
GetHashCode()

傳回這個實例的哈希碼。

GetHashCode()

傳回這個實例的哈希碼。

(繼承來源 Attribute)
GetType()

取得目前實例的 Type

(繼承來源 Object)
IsDefaultAttribute()

在衍生類別中覆寫時,指出這個實例的值是否為衍生類別的預設值。

(繼承來源 Attribute)
Match(Object)

在衍生類別中覆寫時,傳回值,指出這個實例是否等於指定的物件。

(繼承來源 Attribute)
MemberwiseClone()

建立目前 Object的淺層複本。

(繼承來源 Object)
ToString()

傳回表示目前 物件的字串。

(繼承來源 Object)

明確介面實作

名稱 Description
_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)

適用於

另請參閱