IPostBackEventHandler 인터페이스

정의

ASP.NET 서버 컨트롤에서 포스트백 이벤트를 처리하기 위해 구현해야 하는 메서드를 정의합니다.

public interface class IPostBackEventHandler
public interface IPostBackEventHandler
type IPostBackEventHandler = interface
Public Interface IPostBackEventHandler
파생

예제

포스트백을 사용 하 여 다시 게시 이벤트 캡처 단추 사용자 지정 서버 컨트롤을 정의 하는 다음 코드 예제는 RaisePostBackEvent 메서드를 발생 시킵니다는 Click 서버의 이벤트입니다.

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

설명

브라우저에서 폼 제출을 정보를 캡처하는 서버 컨트롤을 만들려면이 인터페이스를 구현 해야 합니다. 이 인터페이스를 사용 하는 방법에 대 한 자세한 내용은 참조 하세요. ASP.NET Web Forms 페이지에서 서버 이벤트 처리합니다.

메서드

RaisePostBackEvent(String)

클래스에서 구현될 때, 폼이 서버에 게시되면 발생되는 이벤트를 서버 컨트롤에서 처리할 수 있도록 합니다.

적용 대상

추가 정보