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. (Last updated on: November 16, 2018).
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?

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.

Solution

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.

 

Article ID: Published Date: Last Revised Date: Platform: Control:
7135 11/01/2016 11/01/2016 ASP.NET MVC Grid
Tags:
Did you find this information helpful?
Add Comment
You must log in to leave a comment

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