Ticket Q571634
Visible to All Users

GridView - Callback error handling

created 11 years ago

Hello,

Today I'm trying to properly handle the grid callback method. I want to be able to set a custom error message ( via javascript) without throwing an Exception in the gridview's controller callback method. Is there any good way to achive this?

Answers approved by DevExpress Support

created 11 years ago (modified 11 years ago)

Hi,
Yes, handle the ASPxClientGridView.CallbackError Event for this purpose. For instance:

C#
... settings.ClientSideEvents.CallbackError = "function(s, e) { alert(e.message); }";

Thanks,
Alessandro.
Updated by Artem:
Yes, the ASPxClientGridView.CallbackError event is fired if an exception is thrown during a callback on the server-side. Please refer to the Handling Callback Exceptions on Client article to learn more about this. If you want to set a custom error text in a special row at the bottom of the grid's Edit Form use the GridViewExtension.SetEditErrorText method for this task. You can see how it works in the GridView - Edit Modes demo.
This event is raised only after an exception is thrown on the server side. Thus, there is no way to fire it without this condition. It's also not quite clear why you want to use this event if you catch an exception using your own tool. If you want to inform the client side about an error, you can pass information about it to a view using ViewData, send this information to the client side, and display it using the MVCxClientGlobalEvents.EndCallback event (see the ASP.NET MVC - Provide the capability to handle the CallbackError event globally (implement an ASPxGlobalEvents equivalent) thread).

    Show previous comments (5)
    Artem (DevExpress Support) 11 years ago

      You're welcome, Adam.
      Let me know if you need further assistance.

        the 's' and the 'e' that line of code below don't do anything but display a popup with the html source code of my page.  There is no error there anywhere.
        settings.ClientSideEvents.CallbackError = "function(s, e) { alert('this is useless…');  }";

        Artem (DevExpress Support) 10 years ago

          Hi,

          To process your inquiry more efficiently, I've moved it to a separate thread created on your behalf:
          The client-side CallbackError event cannot be handled
          Please refer to it for further correspondence.

          Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

          Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.