﻿var _PageRequestManager = Sys.WebForms.PageRequestManager.getInstance();

// call ApplicationLoadHandler on each page load (on the client)
Sys.Application.add_load(ApplicationLoadHandler)

// on each non async request tell the PRM to execute InitializeRequest for each request
function ApplicationLoadHandler(sender, args) {
	if (!_PageRequestManager.get_isInAsyncPostBack()) {
		_PageRequestManager.add_initializeRequest(InitializeRequest);
	}
}

// cancel any async request that is made during the execution of the previous async request
function InitializeRequest(sender, args) {
	if (_PageRequestManager.get_isInAsyncPostBack()) {
		args.set_cancel(true);
	}
}
