We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to return Custom message from Controller when CRUD action fails?

Platform: ASP.NET MVC |
Control: Grid
Tags: ejgrid, grid

In some cases, we may like to return a custom message from the controller after completing CRUD operations such that when an operation fails at server side.


We can return the custom message from controller by throwing exception and handling it at client side using the ActionFailure event of the Grid.

Grid Rendering Code.


Code Behind


2. Handle the returned message in the ActionFailure event of the Grid.


Solution #2: We can also, add the exception message to the response header and fetch the message in the arguments of the ActionFailure event of the Grid at client side.



Handle the exception message from the response header using the getResponseHeader method of the args.error argument of the ActionFailure event.


2X faster development

The ultimate ASP.NET MVC UI toolkit to boost your development speed.
You must log in to leave a comment
Jan 29, 2019

The code below fires correctly on the grid  ActionFailure but the alert message show "Undefined". Please help. I'm using EJ2 version 16.4500.0.48.

2. Handle the returned message in the ActionFailure event of the Grid.

function failure(args) { 
        alert(args.error.statusText); //get the exception message          
Jishnu Chandran
Oct 04, 2019

_code xxxxx1. 1. list text herehere_


Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile