Aracılığıyla paylaş


DataBindingHandlerAttribute Oluşturucular

Tanım

DataBindingHandlerAttribute sınıfının yeni bir örneğini başlatır.

Aşırı Yüklemeler

DataBindingHandlerAttribute()

Parametre kullanmadan sınıfın DataBindingHandlerAttribute yeni bir örneğini başlatır. Bu, parametresiz oluşturucudur.

DataBindingHandlerAttribute(String)

Belirtilen tür adıyla sınıfının yeni bir örneğini DataBindingHandlerAttribute başlatır.

DataBindingHandlerAttribute(Type)

Belirtilen Typesınıfının yeni bir örneğini DataBindingHandlerAttribute başlatır.

DataBindingHandlerAttribute()

Parametre kullanmadan sınıfın DataBindingHandlerAttribute yeni bir örneğini başlatır. Bu, parametresiz oluşturucudur.

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

Örnekler

Aşağıdaki kod örneği oluşturucuyu DataBindingHandlerAttribute kullanır.

// 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

Şunlara uygulanır

DataBindingHandlerAttribute(String)

Belirtilen tür adıyla sınıfının yeni bir örneğini DataBindingHandlerAttribute başlatır.

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)

Parametreler

typeName
String

Veri bağlama işleyicisinin Typetam adı.

Örnekler

Aşağıdaki kod örneği, Web denetimi için özel DataBindingHandler bir sınıf atamak için oluşturucuyu kullanırDataBindingHandlerAttribute.

// 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

Açıklamalar

Bu oluşturucunun tür adı, derleme adı da dahil olmak üzere türün tam adıdır.

Şunlara uygulanır

DataBindingHandlerAttribute(Type)

Belirtilen Typesınıfının yeni bir örneğini DataBindingHandlerAttribute başlatır.

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

Parametreler

type
Type

Type veri bağlama işleyicisi için.

Örnekler

Aşağıdaki kod örneği, tasarımcı tarafından düzenleme modunda kullanılacak adlı MyDataBindingHandlerbir veri bağlama işleyicisi tanımlar. Düzenleme modundan çıkarken özellik Text değeri görüntülenir.


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

Açıklamalar

Bu özniteliğin söz dizimi şöyledir:

[DataBindingHandlerAttribute  
  (typeof(dataBindingHandlerType))]  

Şunlara uygulanır