Export (0) Print
Expand All

DataBindingHandlerAttribute Class

Specifies a design-time class that performs data binding of controls within a designer. This class cannot be inherited.

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

[AttributeUsageAttribute(AttributeTargets.Class)] 
public sealed class DataBindingHandlerAttribute : Attribute
/** @attribute AttributeUsageAttribute(AttributeTargets.Class) */ 
public final class DataBindingHandlerAttribute extends Attribute
AttributeUsageAttribute(AttributeTargets.Class) 
public final class DataBindingHandlerAttribute extends Attribute
Not applicable.

For more information about using attributes, see Extending Metadata Using Attributes.

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.";
    }
  }

}


package CustomControls;

import System.*;
import System.Collections.*;
import System.Web.UI.*;
import System.Web.UI.Design.*;
import System.Web.UI.WebControls.*;
import System.ComponentModel.*;
import System.ComponentModel.Design.*;

/** @attribute DataBindingHandler(MyDataBindingHandler.class)
    @attribute ToolboxData("<{0}:MyLabel runat=server></{0}:MyLabel>")
 */

public class MyLabel extends Label
{
    public MyLabel()
    {
        // Insert your code here.
    } //MyLabel
} //MyLabel

public class MyDataBindingHandler extends DataBindingHandler
{
    public void DataBindControl(IDesignerHost host, Control control)
    {
        ((Label)control).set_Text("Added by data binding handler.");
    } //DataBindControl
} //MyDataBindingHandler

System.Object
   System.Attribute
    System.Web.UI.DataBindingHandlerAttribute

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Windows 98, Windows Server 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0, 1.1, 1.0

Community Additions

ADD
Show:
© 2014 Microsoft