Button.IPostBackEventHandler.RaisePostBackEvent Method (String)


Raises events for the Button control when it posts back to the server.

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

Private Sub RaisePostBackEvent (
	eventArgument As String
	Implements IPostBackEventHandler.RaisePostBackEvent


Type: System.String

The argument for the event.

This event is used internally by the Button control, when it is clicked, to raise a Click event, and if defined, a Command event.

The following code example demonstrates how to override the IPostBackEventHandler.RaisePostBackEvent method so that it always raises the OnClick event in a custom Button control.

<System.Security.Permissions.PermissionSetAttribute(System.Security.Permissions.SecurityAction.Demand, Name:="FullTrust")> _
Public Class CustomButtonRaisePostBackEvent
    Inherits System.Web.UI.WebControls.Button

    Private message As String = System.String.Empty

    Protected Overrides Sub Render(ByVal writer As System.Web.UI.HtmlTextWriter)
        ' Render a HTML submit button.
        writer.Write("<INPUT TYPE='submit' name='" + Me.UniqueID + "' value='Click Me' />")
        writer.Write("<BR>" + message)
    End Sub

    ' Note: VB.NET does not allow one to re-implement a base class interface, whereas C# does.
    ' Hence, just use the base class's PostBackEventHandler's RaisePostBackEvent method,
    ' which calls the OnClick method.

    Protected Overrides Sub OnClick(ByVal e As System.EventArgs)
        message = "RaisePostBackEvent method successful!"
    End Sub
End Class

.NET Framework
Available since 1.1
Return to top