DataBindingHandlerAttribute Construtores

Definição

Inicializa uma nova instância da classe DataBindingHandlerAttribute.Initializes a new instance of the DataBindingHandlerAttribute class.

Sobrecargas

DataBindingHandlerAttribute()

Inicializa uma nova instância da classe DataBindingHandlerAttribute não usando nenhum parâmetro.Initializes a new instance of the DataBindingHandlerAttribute class using no parameters. Esse é o construtor sem parâmetros.This is the parameterless constructor.

DataBindingHandlerAttribute(String)

Inicializa uma nova instância da classe DataBindingHandlerAttribute com o nome do tipo especificado.Initializes a new instance of the DataBindingHandlerAttribute class with the specified type name.

DataBindingHandlerAttribute(Type)

Inicializa uma nova instância da classe DataBindingHandlerAttribute do Type especificado.Initializes a new instance of the DataBindingHandlerAttribute class of the specified Type.

DataBindingHandlerAttribute()

Inicializa uma nova instância da classe DataBindingHandlerAttribute não usando nenhum parâmetro.Initializes a new instance of the DataBindingHandlerAttribute class using no parameters. Esse é o construtor sem parâmetros.This is the parameterless constructor.

public:
 DataBindingHandlerAttribute();
public DataBindingHandlerAttribute ();
Public Sub New ()

Exemplos

O exemplo de código a seguir usa o DataBindingHandlerAttribute Construtor.The following code example uses the DataBindingHandlerAttribute constructor.

// The following example uses the Default
// DataBindingHandlerAttribute constructor.
using System;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Security.Permissions;

namespace MyTextCustomControl
{
   [ DataBindingHandlerAttribute() ]
   [AspNetHostingPermission(SecurityAction.Demand, 
      Level=AspNetHostingPermissionLevel.Minimal)]
   public sealed class MyTextBox : TextBox
   {
      protected override void Render(HtmlTextWriter output)
      {
         output.Write("This class uses the DataBindingHandlerAttribute class.");
      }
   }
}
' The following example uses the Default
' DataBindingHandlerAttribute constructor.
Imports System.Web
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Security.Permissions

Namespace MyTextCustomControl

 <DataBindingHandlerAttribute()>  _
 <AspNetHostingPermission(SecurityAction.Demand, _
   Level:=AspNetHostingPermissionLevel.Minimal)> _
 Public NotInheritable Class MyTextBox
   Inherits TextBox
   
   Protected Overrides Sub Render(output As HtmlTextWriter)
      output.Write("This class uses the DataBindingHandlerAttribute class.")
   End Sub

 End Class
End Namespace 'MyTextCustomControl

Aplica-se a

DataBindingHandlerAttribute(String)

Inicializa uma nova instância da classe DataBindingHandlerAttribute com o nome do tipo especificado.Initializes a new instance of the DataBindingHandlerAttribute class with the specified type name.

public:
 DataBindingHandlerAttribute(System::String ^ typeName);
public DataBindingHandlerAttribute (string typeName);
new System.Web.UI.DataBindingHandlerAttribute : string -> System.Web.UI.DataBindingHandlerAttribute
Public Sub New (typeName As String)

Parâmetros

typeName
String

O nome totalmente qualificado do manipulador de associação de dados Type.The fully qualified name of the data-binding handler Type.

Exemplos

O exemplo de código a seguir usa o DataBindingHandlerAttribute construtor para designar uma DataBindingHandler classe personalizada para o controle da Web.The following code example uses the DataBindingHandlerAttribute constructor to designate a custom DataBindingHandler class for the Web control.

// The following example uses the 
// DataBindingHandlerAttribute(String) constructor to designate
// the custom DataBindingHandler class, named MyDataBindingHandler,
// for the custom MyWebControl class.
using System;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.Design;
using System.ComponentModel.Design;
using System.Security.Permissions;

namespace MyTextCustomControl
{
   [ DataBindingHandlerAttribute("MyTextCustomControl.MyDataBindingHandler") ]
   [AspNetHostingPermission(SecurityAction.Demand, 
      Level=AspNetHostingPermissionLevel.Minimal)]
   public sealed class MyWebControl : WebControl
   {
      protected override void Render(HtmlTextWriter output)
      {
         output.Write("This class uses the DataBindingHandlerAttribute class.");
      }
   }

   public class MyDataBindingHandler : TextDataBindingHandler
   {
      public override void DataBindControl(IDesignerHost host, Control myControl)
      {
         ((TextBox)myControl).Text = "Added by MyDataBindingHandler";
      }
   }
}
' The following example uses the 
' DataBindingHandlerAttribute(String) constructor to designate
' the custom DataBindingHandler class, named MyDataBindingHandler,
' for the custom MyWebControl class.
Imports System.Web
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Web.UI.Design
Imports System.ComponentModel.Design
Imports System.Security.Permissions

Namespace MyTextCustomControl

 <DataBindingHandlerAttribute("MyTextCustomControl.MyDataBindingHandler")>  _
 <AspNetHostingPermission(SecurityAction.Demand, _
   Level:=AspNetHostingPermissionLevel.Minimal)> _
 Public NotInheritable Class MyWebControl
   Inherits WebControl
   
   Protected Overrides Sub Render(output As HtmlTextWriter)
      output.Write("This class uses the DataBindingHandlerAttribute class.")
   End Sub
 End Class


 Public Class MyDataBindingHandler
   Inherits TextDataBindingHandler
   
   Public Overrides Sub DataBindControl(host As IDesignerHost, myControl As Control)
      CType(myControl, TextBox).Text = "Added by MyDataBindingHandler"
   End Sub
 End Class
End Namespace 'MyTextCustomControl

Comentários

O nome do tipo para esse construtor é o nome totalmente qualificado do tipo, incluindo seu nome de assembly.The type name for this constructor is the fully qualified name of the type, including its assembly name.

Aplica-se a

DataBindingHandlerAttribute(Type)

Inicializa uma nova instância da classe DataBindingHandlerAttribute do Type especificado.Initializes a new instance of the DataBindingHandlerAttribute class of the specified Type.

public:
 DataBindingHandlerAttribute(Type ^ type);
public DataBindingHandlerAttribute (Type type);
new System.Web.UI.DataBindingHandlerAttribute : Type -> System.Web.UI.DataBindingHandlerAttribute
Public Sub New (type As Type)

Parâmetros

type
Type

O Type para o manipulador de associação de dados.The Type for the data-binding handler.

Exemplos

O exemplo de código a seguir define um manipulador de vinculação de dados, chamado MyDataBindingHandler , a ser usado pelo designer no modo de edição.The following code example defines a data-binding handler, named MyDataBindingHandler, to be used by the designer in editing mode. Ao sair do modo de edição, o Text valor da propriedade é exibido.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.";
    }
  }
}


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
      
    End Class
   
    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
      
    End Class
    
End Namespace 'CustomControls 

Comentários

A sintaxe para esse atributo é:The syntax for this attribute is:

[DataBindingHandlerAttribute  
  (typeof(dataBindingHandlerType))]  

Aplica-se a