Mehul Harry's DevExpress Blog

This Blog

News


Mehul Harry is the DevExpress Web Program Manager. Follow him on twitter: @Mehulharry

Subscribe (RSS, Email)

Archives

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
Bookmark and Share

Comments

Shankar

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

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)

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)

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

Alexander Shabanov

But how we can alert database errors? Suppose in callback i use method which works with database and there is database error message. How i can show it on client side via alert message?

September 24, 2012 2:50 AM

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
LIVE CHAT

Chat is one of the many ways you can contact members of the DevExpress Team.
We are available Monday-Friday between 7:30am and 4:30pm Pacific Time.

If you need additional product information, write to us at info@devexpress.com or call us at +1 (818) 844-3383

FOLLOW US

DevExpress engineers feature-complete Presentation Controls, IDE Productivity Tools, Business Application Frameworks, and Reporting Systems for Visual Studio, Delphi, HTML5 or iOS & Android development. Whether using WPF, ASP.NET, WinForms, HTML5 or Windows 10, DevExpress tools help you build and deliver your best in the shortest time possible.

Copyright © 1998-2018 Developer Express Inc.
All trademarks or registered trademarks are property of their respective owners