Expand Minimize

Page.RegisterRequiresRaiseEvent Method

Registers an ASP.NET server control as one requiring an event to be raised when the control is processed on the Page object.

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

public virtual void RegisterRequiresRaiseEvent(
	IPostBackEventHandler control
)

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.

void DisplayUserName(Object sender, EventArgs ea) 
{
   Response.Write("Welcome to " + Server.HtmlEncode(userName.Text));
}
void RaiseEvent(Object sender, EventArgs ea)
{
   // Raise a post back event for a control.
   this.RaisePostBackEvent(userButton, "");
}
void Page_Load(Object sender, EventArgs ea)
{
   // Register a control as one that requires postback handling.
   this.RegisterRequiresRaiseEvent(userButton);
}

.NET Framework

Supported in: 4.5.2, 4.5.1, 4.5, 4, 3.5, 3.0, 2.0, 1.1, 1.0

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

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

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft