Mar 2, 2008

cancel request vs abort reqeust

In asp.net ajax framework, you can cancel request before the request is submitted to the server, you can aborted the request after the request is submitted to the server and before the response is received.

function onInitializeRequest(sender, args){
    var prm = Sys.WebForms.PageRequestManager.getInstance();
    if (prm.get_isInAsyncPostBack() & args.get_postBackElement().id == 'CancelRefresh') {
            prm.abortPostBack();
    }else if (prm.get_isInAsyncPostBack() & args.get_postBackElement().id == 'RefreshButton') {
            args.set_cancel(true);
            ActivateAlertDiv('visible', 'Still working on previous request.');
            }
            else if (!prm.get_isInAsyncPostBack() & args.get_postBackElement().id == 'RefreshButton') {
            ActivateAlertDiv('visible', 'Retrieving headlines.');
            }