views:

14

answers:

1

Hi,

Thisis the code I use to display an aspxloadingpanel with an ms update panel:

var prm = Sys.WebForms.PageRequestManager.getInstance();
prm.add_initializeRequest(initializeRequest);
prm.add_pageLoaded(pageLoaded);

function initializeRequest(sender, args) {
    pbar.Show();
}

function pageLoaded(sender, args) {
    var panels = args.get_panelsUpdated();
    if (panels.length > 0) {
        pbar.Hide();
    }
}

However when an error occurs on this page, the loading panel continuously remains on the screen...How can I catch errors so that instead it would actually show the error.

Thanks,

Tim

+1  A: 

You could use the endRequest event:

prm.add_endRequest(endRequestHandler);

function endRequestHandler(sender, args) {
    if (args.get_error() != undefined) {
        // An error occured
        var errorMessage = args.get_error().message;
        args.set_errorHandled(true);
        alert(errorMessage);
    } else {
        // The request completed successfully
    }
}
Darin Dimitrov