DataBindingHandlerAttribute Class (System.Web.UI)

Switch View :
ScriptFree
.NET Framework Class Library
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)
Syntax

Visual Basic (Declaration)
<AttributeUsageAttribute(AttributeTargets.Class)> _
<AspNetHostingPermissionAttribute(SecurityAction.LinkDemand, Level := AspNetHostingPermissionLevel.Minimal)> _
Public NotInheritable Class DataBindingHandlerAttribute _
	Inherits Attribute
Visual Basic (Usage)
Dim instance As DataBindingHandlerAttribute
C#
[AttributeUsageAttribute(AttributeTargets.Class)]
[AspNetHostingPermissionAttribute(SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
public sealed class DataBindingHandlerAttribute : Attribute
Visual C++
[AttributeUsageAttribute(AttributeTargets::Class)]
[AspNetHostingPermissionAttribute(SecurityAction::LinkDemand, Level = AspNetHostingPermissionLevel::Minimal)]
public ref class DataBindingHandlerAttribute sealed : public Attribute
JScript
public final class DataBindingHandlerAttribute extends Attribute
Remarks

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

Examples

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.

Visual Basic

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 'New

    End Class 'MyLabel

    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 'DataBindControl

    End Class 'MyDataBindingHandler

End Namespace 'CustomControls 



C#

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 Security

Inheritance Hierarchy

System.Object
  System.Attribute
    System.Web.UI.DataBindingHandlerAttribute
Thread Safety

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

Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Version Information

.NET Framework

Supported in: 3.5, 3.0, 2.0, 1.1, 1.0
See Also

Reference