Handling Callback Exceptions on the Client Side

  • 2 minutes to read

A DevExpress ASP.NET Ajax-enabled control automatically catches server exceptions that occur within its server-side event handler, and passes corresponding error information to the client for processing. On the client side, use the control's CallbackError client event to process the error at the control level, or handle the ASPxGlobalEvents control's ASPxClientGlobalEvents.CallbackError client event to process the error globally (across all DevExpress web controls).

Handle either of these client events to perform specific client-side actions, such as to display explanatory text or an image related to the error.


This example demonstrates how to use the ASPxClientNavBar.CallbackError event to process a server error.

<%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" 
Inherits="_Default" %>
<%@ Register assembly="DevExpress.Web.v8.3, Version=, Culture=neutral, 
PublicKeyToken=b88d1754d700e49a" namespace="DevExpress.Web.ASPxNavBar" tagprefix="dxnb" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 

<script runat="server">
    protected void Page_Load(object sender, EventArgs e){
    protected void ASPxNavBar1_ExpandedChanged(object source, 
      DevExpress.Web.NavBarGroupEventArgs e) {
        throw new Exception("A new exception.");

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Untitled Page</title>
    <form id="form1" runat="server">

        <dxnb:ASPxNavBar ID="ASPxNavBar1" runat="server" AutoCollapse="True" 
            EnableCallBacks="True" onexpandedchanged="ASPxNavBar1_ExpandedChanged" 
                <dxnb:NavBarGroup Text="Products">
                        <dxnb:NavBarItem Text="ASP.NET Components">
                        <dxnb:NavBarItem Text=".NET WinForms Components">
                        <dxnb:NavBarItem Text="VCL Components">
                <dxnb:NavBarGroup Expanded="False" Text="Support">
                        <dxnb:NavBarItem Text="Client Center">
                        <dxnb:NavBarItem Text="Online Help">
                        <dxnb:NavBarItem Text="Contacts">
            <ClientSideEvents CallbackError="function(s, e) {
        if (e.message=='A new exception.') {
        alert('The CallbackError event is raised!'); }
            }" />