Blogs

News

Email Subscriptions

Mehul Harry's DevExpress Blog

Ajax Callback Error in ASP.NET Part 2 – Client Side Popup

     

A new event was added to all of our ASP.NET controls that use callbacks. The CallbackError event handler is a client-side event and can be used to handle those pesky callback errors. This event captures and displays callback errors using the client-side JavaScript. The event still require the use of an ASPxHttpHandler module, which is responsible for intercepting the callback error. However, this event now gives you the choice of displaying the error on the client side.

To use it, override the event using the smart tag of the control or you can add the event code using source HTML view. Here is an example that shows how the ASPxGridView will use a JavaScript alert popup to display the error message:

<dxwgv:ASPxGridView ID="ASPxGridView1" runat="server" AutoGenerateColumns="False"
CssFilePath="~/App_Themes/Plastic Blue/{0}/styles.css" CssPostfix="PlasticBlue"
DataSourceID="SqlDataSource1">
<ClientSideEvents
CallbackError="function(s, e) {
alert(e.message);
e.handled = true;
}" />

With this new event, there are now three different way to handle and respond to callback errors:

  1. Server side – Respond to the control
  2. Server side – Redirect to a general error page
  3. Client side

Which method do you prefer to respond to callback errors with?

Published Aug 01 2008, 05:07 PM by Mehul Harry (DevExpress)
Technorati tags: How-To, Tutorial, ASP.NET, ASPxGridView
Bookmark and Share

Comments

 

Shankar said:

Nice post. I was looking for one like this to handle database posting errors in Oracle using XPO and communicate it effectively to the user. I am a novice to your controls.  Would you publish a cheat sheet on the Events, Properties (there are just too many of them to comprehend and use it effectively)

August 2, 2008 1:10 PM
 

Kamran Shahid said:

What I need is Stack Trace with the error Message.

Is it possible to Get Stack Trace or not ?

August 4, 2008 2:34 AM
 

Mehul Harry (DevExpress) said:

Hi Kamran,

For now it's impossible. We only send the error message to the client-side.

A couple weeks ago, a customer wanted to send a custom error message to the client-side. So we've added a suggestion about it and I recommend tracking it: www.devexpress.com/issue=S30328

August 4, 2008 1:42 PM
 

Mehul Harry (DevExpress) said:

Hi Shankar,

Check out part 1 to this post which has a screencast that shows how to redirect to a general error page. However, for posting errors, you may want to either use debug or log them somewhere because callbacks are not the best place to catch them. Here is the screencast: community.devexpress.com/.../video-how-to-handle-an-asp-net-ajax-callback-error.aspx

August 4, 2008 6:00 PM

About Mehul Harry (DevExpress)

Mehul Harry is an ASP.NET technical evangelist at Developer Express. You can reach him directly at mharry@DevExpress.com. You can also follow him on Twitter: http://twitter.com/mehulharry
More from DevExpress
Live Chat
Have a pre-sales question?
Need assistance with your evaluation?
We are here to help.
Chat is one of the many ways you can contact members of the DevExpress Team. We are available Monday-Friday between 8:30am and 5:00pm Pacific Time.
If you need additional product information, require pre-sales assistance, or want help with your order, write to us at info@devexpress.com or call us at
+1 (818) 844-3383.