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.

For a list of all members of this type, see DataBindingHandlerAttribute Members.

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

[Visual Basic]
<AttributeUsage(AttributeTargets.Class)>
NotInheritable Public Class DataBindingHandlerAttribute
   Inherits Attribute
[C#]
[AttributeUsage(AttributeTargets.Class)]
public sealed class DataBindingHandlerAttribute : Attribute
[C++]
[AttributeUsage(AttributeTargets::Class)]
public __gc __sealed class DataBindingHandlerAttribute : public
   Attribute
[JScript]
public
   AttributeUsage(AttributeTargets.Class)
class DataBindingHandlerAttribute extends Attribute

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.

Remarks

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

Example

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

}


[C++] 

#using <mscorlib.dll>
#using <System.dll>
#using <System.Web.dll>
#using <System.Design.dll>
using namespace System;
using namespace System::Collections;
using namespace System::Web::UI;
using namespace System::Web::UI::Design;
using namespace System::Web::UI::WebControls;
using namespace System::ComponentModel;
using namespace System::ComponentModel::Design;

public __gc class MyDataBindingHandler : public DataBindingHandler
{
public:
   void DataBindControl(IDesignerHost* host, Control* control)
   {
      (dynamic_cast<Label*>(control))->Text = S"Added by data binding handler.";
   }
};

[
   DataBindingHandler(__typeof(MyDataBindingHandler)),
   ToolboxData(S"< {0}:MyLabel runat=server></ {0}:MyLabel>")
]
public __gc class MyLabel : public Label
{
public:
   MyLabel()
   {
      // Insert your code here.
   }
};

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Namespace: System.Web.UI

Platforms: Windows 2000, Windows XP Professional, Windows Server 2003 family

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

See Also

DataBindingHandlerAttribute Members | System.Web.UI Namespace | Attribute

Show:
© 2014 Microsoft