Aborting AJAX Requests
The ASP.NET AJAX script library provides a simple way to abort asynchronous postback requests in cases where users decide they don't need data they originally requested. This can be done without tying into different PageRequestManager events. Instead, the abortPostBack() method can be called as shown in the code that follows. For more information on aborting AJAX requests you can read my latest .NET Insight article here.
function btnAbort_Click()
{
var prm = Sys.WebForms.PageRequestManager.getInstance();
if (prm.get_isInAsyncPostBack())
{
prm.abortPostBack();
alert("Postback aborted!");
}
else
{
alert("No postback operation is in progress.");
}
}
{
var prm = Sys.WebForms.PageRequestManager.getInstance();
if (prm.get_isInAsyncPostBack())
{
prm.abortPostBack();
alert("Postback aborted!");
}
else
{
alert("No postback operation is in progress.");
}
}