Suppress Ajax Timeout Messages

4 posts, 0 answers
  1. LeBear
    LeBear avatar
    233 posts
    Member since:
    May 2006

    Posted 17 Jan 2008 Link to this post

    I'm handling Ajax timeouts.  Is there a way to suppress the alert that pops up?  (Sys.WebForms.PageRequestManagerTimeoutException: The server request timed out.)
  2. Giuseppe
    Admin
    Giuseppe avatar
    2363 posts

    Posted 18 Jan 2008 Link to this post

    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
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. LeBear
    LeBear avatar
    233 posts
    Member since:
    May 2006

    Posted 26 Mar 2008 Link to this post

    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!
  5. Sebastian
    Admin
    Sebastian avatar
    9934 posts

    Posted 27 Mar 2008 Link to this post

    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
Back to Top