This is a migrated thread and some comments may be shown as answers.

Suppress Ajax Timeout Messages

3 Answers 196 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
LeBear
Top achievements
Rank 1
LeBear asked on 18 Jan 2008, 02:10 AM
I'm handling Ajax timeouts.  Is there a way to suppress the alert that pops up?  (Sys.WebForms.PageRequestManagerTimeoutException: The server request timed out.)

3 Answers, 1 is accepted

Sort by
0
Giuseppe
Telerik team
answered on 18 Jan 2008, 09:52 AM
Hello Barry,

As RadAjax Prometheus is based on the ASP.NET AJAX framework we would suggest you to review the following ASP.NET AJAX article on error handling here that describes the desired functionality (section "Using Client Script to Customize Error Handling").


Best wishes,
Manuel
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
LeBear
Top achievements
Rank 1
answered on 27 Mar 2008, 12:47 AM
If anyone is working on this, I thought I would update...

The end request handler is certainly the way to go.  As is usually the case, however, it's hard to find what information is available in such a handler.  I found the argument documented very well here: http://asp.net/AJAX/Documentation/Live/ClientReference/Sys.WebForms/EndRequestEventArgsClass/default.aspx

I created an error handler that specifically checks for a timeout, though you could check for more if you like:

    Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequestHandler); 
    function EndRequestHandler(sender, args){ 
        showTrace('Checking Response for request from gadget ' + activeGadgetID_gin); 
        if (args.get_response().get_timedOut()){ 
            showTrace('Request Timed Out!'); 
            args.set_errorHandled(true); 
        } else { 
            if (args.get_error() != undefined){ 
                if (document.getElementById('TraceFlag').value == "1"){ 
                    showTrace('Error: ' + args.get_error().message + '(' + args.get_response().get_statusCode() + ')'); 
                } else { 
                    alert('Error: ' + args.get_error().message + '(' + args.get_response().get_statusCode() + ')') 
                } 
            } 
        } 
    } 
 

FYI, the showTrace calls are debugging output for my application that, if a flag is set, will display the message in a special window on the page.  As such, you can ignore those calls.  Oh, and I also have a variable on the page, activeGadgetID_gin that just keeps track of which gadget is currently executing.

And... when there's a timeout, I have another mechanism elsewhere that handles it - imperfectly.  I'm going to change it so that this routine triggers my timeout handler.

I hope this helps someone.
Enjoy!
0
Sebastian
Telerik team
answered on 27 Mar 2008, 07:59 AM
Hello Barry,

Thank you for posting your solution in our public forum - this can be useful for other community members which would like to use similar approach. I updated your Telerik points for the involvement.

Best regards,
Stephen
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
Tags
Ajax
Asked by
LeBear
Top achievements
Rank 1
Answers by
Giuseppe
Telerik team
LeBear
Top achievements
Rank 1
Sebastian
Telerik team
Share this question
or