DataBindingHandlerAttribute Constructor (Type)
Collapse the table of content
Expand the table of content

DataBindingHandlerAttribute Constructor (Type)

 

Initializes a new instance of the DataBindingHandlerAttribute class of the specified Type.

Namespace:   System.Web.UI
Assembly:  System.Web (in System.Web.dll)

public DataBindingHandlerAttribute(
	Type type
)

Parameters

type
Type: System.Type

The Type for the data-binding handler.

The syntax for this attribute is:

[DataBindingHandlerAttribute
  (typeof(dataBindingHandlerType))]

The following code example defines a data-binding handler, named MyDataBindingHandler, to be used by the designer in editing mode. 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.";
    }
  }

}

.NET Framework
Available since 1.1
Return to top
Show:
© 2016 Microsoft