Documentation for: ASP.NET Ajax Version 1.0

This documentation is for a previous version. For the current released version, see the ASP.NET Ajax documentation on MSDN.

 

 

 

 

 

 

 

Sys.WebForms.PageRequestManager initializeRequest Event

Raised during the initialization of the asynchronous postback.

Syntax

Sys.WebForms.PageRequestManager.instance.add_initializeRequest(initializeRequestHandler)
Sys.WebForms.PageRequestManager.instance.remove_initializeRequest(initializeRequestHandler)

Term

Definition

initializeRequestHandler

The name of the handler method that will be called.

Remarks

The initializeRequest method is raised before processing of the asynchronous request starts. You can use this event to cancel a postback.

For more information about the PageRequestManager event model, see Working with PageRequestManager Events.

Example

The following example shows how to use the initializeRequest event to cancel an asynchronous postback. Script in the initializeRequest event handler determines whether an asynchronous postback is currently in progress by using the isInAsyncPostBack property of the PageRequestManager class. If a postback is in progress, the postBackElement property of the Sys.WebForms.InitializeRequestEventArgs class is used to determine the ID of the element that caused the postback. If the ID matches the ID of a button that cancels the postback, the abortPostBack method is called. Otherwise, the current request is canceled by using the cancel property of the Sys.CancelEventArgs class.