RadGrid for ASP.NET

Error handling for AJAX requests Send comments on this topic.
AJAX > What you should have in mind > Error handling for AJAX requests

Glossary Item Box

You can provide your own error handler for AJAX requests if you wish to block or handle those errors in a specific way. Keep in mind that thus you can intercept invalid request content type errors, Server.Transfer calls, etc. but not generic ASP.NET server exceptions.

For this purpose Telerik RadGrid provides a special property AjaxRequestError. You can either supply the name of a javascript function or executable code like "alert(e.message)"

The JavaScript handler function should have the following signature:

ASPX/ASCX Copy Code
AjaxRequestErrorHandler(e, clientID)
 {
   ...
 }

It must be defined ABOVE the code clock which contains your AJAX enabled control.

ASPX/ASCX Copy Code
<rada:RadAjaxManager ID="RadAjaxManager1" runat="server" OnAjaxRequestError=””…/>
or
<rad:RadGrid ID="RadGrid1" runat="server" OnAjaxRequestError=””…/>

or

ASPX/ASCX Copy Code
<script type=”/javascript”>
  
function HandleAJAXError(e, clientID)
  {
      alert(e.message);
  }
</script>

<
rada:RadAjaxManager OnAjaxRequestError=”HandleAJAXError”…/>
or
<rad:RadGrid ID="RadGrid1" runat="server" OnAjaxRequestError=””…/>

 

 In case you need to get a hold of the Response object in ajax call on the client, you can use the OnRequestError event which will be raised in case of status different than 200. Here is an example syntax:

 <script type="text/javascript">
        function RequestError(sender, e)
        {
            alert(e.Status);
            alert(e.ResponseText);
            alert(e.ResponseHeaders);
            return false;
        }
 </script>