This documentation is archived and is not being maintained.

IPostBackEventHandler Interface

Defines the method ASP.NET server controls must implement to handle postback events.

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

'Declaration
Public Interface IPostBackEventHandler

The IPostBackEventHandler type exposes the following members.

  NameDescription
Public methodRaisePostBackEventWhen implemented by a class, enables a server control to process an event raised when a form is posted to the server.
Top

To create a server control that captures form submission information from the browser, you must implement this interface. For more information on how to use this interface, see Server Event Handling in ASP.NET Web Pages.

The following code example defines a custom button server control that causes postback, captures the postback event using the RaisePostBackEvent method, and raises a Click event on the server.


Imports System
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



.NET Framework

Supported in: 4, 3.5, 3.0, 2.0, 1.1, 1.0

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Show: