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

Load On Demand and Exception handling

3 Answers 261 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Susan Budnik
Top achievements
Rank 2
Susan Budnik asked on 22 Dec 2008, 07:06 PM
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.

3 Answers, 1 is accepted

Sort by
0
Accepted
Atanas Korchev
Telerik team
answered on 23 Dec 2008, 10:43 AM
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.
0
Susan Budnik
Top achievements
Rank 2
answered on 29 Dec 2008, 09:04 PM
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.
0
John
Top achievements
Rank 1
answered on 02 Nov 2012, 10:00 PM
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.
Tags
ComboBox
Asked by
Susan Budnik
Top achievements
Rank 2
Answers by
Atanas Korchev
Telerik team
Susan Budnik
Top achievements
Rank 2
John
Top achievements
Rank 1
Share this question
or