IPostBackEventHandler Arabirim

Tanım

Sunucu denetimlerinin geri gönderme olaylarını işlemek için uygulaması ASP.NET yöntemini tanımlar.

public interface class IPostBackEventHandler
public interface IPostBackEventHandler
type IPostBackEventHandler = interface
Public Interface IPostBackEventHandler
Türetilmiş

Örnekler

Aşağıdaki kod örneği, geri göndermeye neden olan, yöntemini kullanarak RaisePostBackEvent geri gönderme olayını yakalayan ve sunucuda bir olay oluşturan özel bir Click düğme sunucusu denetimini tanımlar.

using System;
using System.Web.UI;
using System.Collections;
using System.Collections.Specialized;

namespace CustomControls {

   [System.Security.Permissions.PermissionSet(System.Security.Permissions.SecurityAction.Demand, Name="FullTrust")]
   public class MyButton: Control, IPostBackEventHandler {

      // Defines the Click event.
      public event EventHandler Click;

      //Invoke delegates registered with the Click event.
      protected virtual void OnClick(EventArgs e) {

         if (Click != null) {
            Click(this, e);
         }
      }

      // Define the method of IPostBackEventHandler that raises change events.
      public void RaisePostBackEvent(string eventArgument){

         OnClick(new EventArgs());
      }

      protected override void Render(HtmlTextWriter output) {
         output.Write("<INPUT TYPE = submit name = " + this.UniqueID +
            " Value = 'Click Me' />");
      }
   }
}
Imports System.Web.UI
Imports System.Collections
Imports System.Collections.Specialized

Namespace CustomControls    
    
    <System.Security.Permissions.PermissionSetAttribute(System.Security.Permissions.SecurityAction.Demand, Name:="FullTrust")> Public Class MyButton
        Inherits Control
        Implements IPostBackEventHandler
        
        ' Define the Click event.
        Public Event Click As EventHandler
        
        
        ' Invoke delegates registered with the Click event.
        Protected Overridable Sub OnClick(e As EventArgs)            
            RaiseEvent Click(Me, e)
        End Sub
        
        
        ' Define the method of IPostBackEventHandler that raises change events.
        Public Sub RaisePostBackEvent(eventArgument As String) _
        Implements IPostBackEventHandler.RaisePostBackEvent
        
            OnClick(New EventArgs())
        End Sub       
        
        
        Protected Overrides Sub Render(output As HtmlTextWriter)
            output.Write("<INPUT TYPE = submit name = " & Me.UniqueID & _
                " Value = 'Click Me' />")
        End Sub
        
    End Class
End Namespace

Açıklamalar

Tarayıcıdan form gönderim bilgilerini yakalayan bir sunucu denetimi oluşturmak için bu arabirimi uygulamanız gerekir. Bu arabirimi kullanma hakkında daha fazla bilgi için bkz. ASP.NET Web Forms Sayfalarında Sunucu Olay İşleme.

Yöntemler

RaisePostBackEvent(String)

Bir sınıf tarafından uygulandığında, sunucu denetiminin bir form sunucuya gönderildiğinde tetiklenen bir olayı işlemesini sağlar.

Şunlara uygulanır

Ayrıca bkz.