Load On Demand and Exception handling

4 posts, 1 answers
  1. Susan Budnik
    Susan Budnik  avatar
    8 posts
    Member since:
    Mar 2008

    Posted 22 Dec 2008 Link to this post

    When an exception occurs during the ItemsRequested event, a RadWindow is displayed to the user with the message "There was an error in the callback."

    Instead, I want the exception to bubble up to Application_Error in global.asax, where I have implemented centralized error handling/logging for the web site. This centralized error handling logs the error and redirects the user to a common error page. 

    I have many other pages in the website where I use RadAjaxManager to perform AJAX-updates. If an exception occurs on the server during one of these AJAX-postbacks, I am able to route the exception through Application_Error by setting web config's customErrors to "On" and setting AllowCustomErrorsRedirect to "true" for the ScriptManager. However, these settings do not seem to have any affect on exceptions that occur during the ItemsRequested event of RadCombo.

    I understand that you can call a custom javascript function by setting the "OnClientItemsRequestFailed" property on RadCombo, or that I can swallow the exception by putting a try/catch block around the code in the OnItemsRequested server-side event handler. However, neither of these options meet my needs.

    Is there a way to tell RadCombo to allow exceptions that occur during the ItemsRequested event to bubble up to Application_Error?

    Thank you.
  2. Answer
    Atanas Korchev
    Admin
    Atanas Korchev avatar
    8462 posts

    Posted 23 Dec 2008 Link to this post

    Hi Donna Padilla,

    RadComboBox load on demand utilizes ASP.NET Callbacks which unfortunately skip the Application_Error event. In a word if there is an exception thrown in your ItemsRequest event handler the Application_Error event won't be fired. The same goes with WebService exceptions. I am afraid the only possible way to log exceptions from the ItemsRequested event is to add a try catch block:

    try {

       //Load on demand code
    }catch (Exception exception)
    {
     myLogger.Log(exception)
    throw exception;
    }

    Regards,
    Albert
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  3. Susan Budnik
    Susan Budnik  avatar
    8 posts
    Member since:
    Mar 2008

    Posted 29 Dec 2008 Link to this post

    Thanks for the explanation - that makes more sense now. I was able to achieve the results I needed, albeit manually. Here is an overview of what I did for anyone else looking for a similar solution:
    1) I put a try/catch block around the code in my ItemsRequested server-side event. In the catch block I log the exception and then rethrow it.
    2) In the OnClientItemsRequestFailed client-side event, I cancel the alert (eventArgs.set_cancel(true)) and then do a post back. In the RaisePostBackEvent handler I check the event argument and then redirect to the custom error page.
  4. John
    John avatar
    3 posts
    Member since:
    Jun 2012

    Posted 02 Nov 2012 Link to this post

    I am having exactly the same issue. Is it possible to bubble up the exception to Application_Error in Global.asax in this situation? How can I achieve it with out any try/catch block in OnItemsRequested
     Thanks.
Back to Top