Export (0) Print
Expand All

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

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0, 1.1, 1.0

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Show:
© 2014 Microsoft