BoldSignEasily embed eSignatures in your .NET applications. Free sandbox with native SDK available.
alert(args.error.statusText);
//get the exception message
[Client side code]
@Html.EJS().Grid("Grid").DataSource(ds => ds.Url("/Home/UrlDatasource").Adaptor("UrlAdaptor").InsertUrl("/Home/Insert")
.RemoveUrl("/Home/Remove").UpdateUrl("Home/Update")).AllowPaging(true).Columns(col =>
{
col.Field("OrderID").HeaderText("Order ID").IsPrimaryKey(true).TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Width("120").Add();
...
}).Toolbar(new List<string>() { "Add", "Edit", "Delete", "Update", "Cancel" }).ActionFailure("failure").EditSettings(edit => { edit.AllowAdding(true).AllowDeleting(true).AllowEditing(true); }).Render()
<script>
function failure(args) {
var errorMessage = args.error[0].error.responseText.split("Exception:")[1].split('<br>')[0]; //extract the message from args
alert(errorMessage);
}
</script>
[Server side code]
public ActionResult Insert(Orders value)
{
var data = order.Where(or => or.OrderID == value.OrderID).FirstOrDefault();
if (data == null)
{
order.Insert(0, value);
}
else
{
throw new Exception("Duplicate values cannot be inserted"); //Add custom exception message
}
return Json(value);
} |