DataBindingHandlerAttribute 类

定义

指定一个设计时类,用于执行设计器内的控件数据绑定。Specifies a design-time class that performs data binding of controls within a designer. 此类不能被继承。This class cannot be inherited.

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

示例

下面的代码示例定义了一个名MyDataBindingHandler为的数据绑定处理程序, 该处理程序将在编辑模式下供设计器使用。The following code example defines a data-binding handler, named MyDataBindingHandler, to be used by the designer in editing mode. 退出编辑模式时, 将Text显示属性值。On exiting the editing mode, the Text property value is displayed.


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 

注解

有关使用特性的详细信息, 请参阅特性For more information about using attributes, see Attributes.

构造函数

DataBindingHandlerAttribute()

不使用任何参数初始化 DataBindingHandlerAttribute 类的新实例。Initializes a new instance of the DataBindingHandlerAttribute class using no parameters. 这就是无参数构造函数。This is the parameterless constructor.

DataBindingHandlerAttribute(String)

用指定的类型名称初始化 DataBindingHandlerAttribute 类的新实例。Initializes a new instance of the DataBindingHandlerAttribute class with the specified type name.

DataBindingHandlerAttribute(Type)

初始化指定的 TypeDataBindingHandlerAttribute 类的新实例。Initializes a new instance of the DataBindingHandlerAttribute class of the specified Type.

字段

Default

定义 DataBindingHandlerAttribute 类的默认特性。Defines the default attribute for the DataBindingHandlerAttribute class.

属性

HandlerTypeName

获取数据绑定处理程序的类型名称。Gets the type name of the data-binding handler.

TypeId

在派生类中实现时,获取此 Attribute 的唯一标识符。When implemented in a derived class, gets a unique identifier for this Attribute.

(继承自 Attribute)

方法

Equals(Object)

确定两个对象实例是否相等。Determines whether two object instances are equal.

GetHashCode()

返回此实例的哈希代码。Returns the hash code for this instance.

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()

返回一个表示当前对象的 string。Returns a string that represents the current object.

(继承自 Object)

显式接口实现

_Attribute.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr)

将一组名称映射为对应的一组调度标识符。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)

适用于

另请参阅