in
Forums
Blogs
Files
Devexpress.Com
ClientCenter
Support Center
DevExpress Channel

This Blog

Syndication

The ASPx Blog - 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 (Developer Express)
Technorati tags: How-To, Tutorial, ASP.NET, ASPxGridView

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 (Developer Express) 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 (Developer Express) 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

Leave a Comment

(required)  
(optional)
(required)  
Verification code: Required
   
Add
Copyright © 1998-2008 Developer Express Inc.
ALL RIGHTS RESERVED