Page.RegisterRequiresRaiseEvent Method (IPostBackEventHandler)
Registers an ASP.NET server control as one requiring an event to be raised when the control is processed on the Page object.
Assembly: System.Web (in System.Web.dll)
Parameters
- control
-
Type:
System.Web.UI.IPostBackEventHandler
The control to register.
Only one server control can be registered per page request. The RegisterRequiresRaiseEvent must be used when the control does not include its control ID in the form post data. Also, the control that is registered must implement the IPostBackEventHandler interface.
The following code example uses the RegisterRequiresRaiseEvent method to register a Button Web server control as requiring an event to be raised. After you have registered the first Button control, you can cause the second Button control declared in the code to post the results of the first button's click event to the page.
Sub DisplayUserName(Sender As Object, e As EventArgs) Response.Write("Welcome to " + Server.HtmlEncode(userName.Text)) End Sub Sub MyRaiseEvent(Sender As Object, e As EventArgs) 'Raises a post back event for a control. Me.RaisePostBackEvent(userButton, "") End Sub Sub Page_Load(Sender As Object, e As EventArgs) 'Registers a control as one that requires postback handling Me.RegisterRequiresRaiseEvent(userButton) End Sub
Available since 1.1