Client-side representation of UpdatePanel controls and ScriptManager

Update panels don't really have a client-side JavaScript representation and will just be available as a DIV or SPAN element in the document. ScriptManager, on the other hand, as a global manager object for all things related to partial updates, finds an interesting client-side alter-ego in PageRequestManager. PageRequestManager is the object that is responsible client-side for managing the lifecycle and events related to UpdatePanel controls. The current instance of PageRequestManager for the page can be obtained like this:

var prm = Sys.WebForms.PageRequestManager.getInstance();

It is this object for example that will enable your client-side code to determine if a partial update is currently pending, by looking at its isInAsyncPostBack property:

if (prm.get_isInAsyncPostBack()) { //...

PageRequestManager also enables you to cancel a partial update:

prm.abortPostBack();

Calling this method unfortunately can't stop the information that is already on its way to the server, it can just instruct the client to ignore the results when they come back. This means that any side effects like database updates won't be cancelled.

The most interesting aspect of PageRequestManger is certainly all the events it exposes that enable client-side code to modify the default behavior of UpdatePanel and that we'll detail in the following section.

PageRequestManager events

All events on PageRequestManager are built using the ASP.NET Ajax pattern ...

Get ASP.NET AJAX UpdatePanel Control now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.