- Home
- Forum
- ASP.NET MVC
- How to show server errors in the editing form when insert/update fails on server?
How to show server errors in the editing form when insert/update fails on server?
Hello
I have a Grid in the ExternalFormTemplate editing mode, with UpdateURL and InsertURL callbacks. How do I show server errors in the ExternalForm template when the callback fails on server?
I have tried an Action like this
public ActionResult CreateCallback(GridItemViewModel value)
{
var err = new {key="Name", errors=new[] {"Name error"}};
var errm = new List<object> { err };
Response.StatusCode = (int)HttpStatusCode.BadRequest;
return new JsonResult
{
Data = errm, JsonRequestBehavior=JsonRequestBehavior.AllowGet
};
}
which correctly triggers ActionFailure event on the client, but, when the ActionFailure event is received, the editing form is already closed.
I have looked at the
https://www.syncfusion.com/kb/6817/how-to-perform-server-side-validation-in-grid
https://www.syncfusion.com/kb/5170/how-to-display-custom-error-message-on-ajax-action-failture
https://www.syncfusion.com/forums/118649/how-to-bind-modelstate-error-to-sync-fusion-grid-for-inline-editing-updating
but I don't want to use separate validation ajax calls, popups/alerts, and I'd rather not build my own HTML to show errors.
So, is it possible to prevent closing the editing form in the case of insert/update error, or, even better, somehow bind the validation errors from the server to the fields in the editing form, something like
@Html.ValidationMessageFor
in the pure MVC?
Thanks, Tom
Hm, sorry, this doesn't answer my question.
My question is not 'how to perform server side validation', the question is 'how to show server errors in the editing form when insert/update fails on server'.
I know how to perform a server validation, and I actually quoted the KB article as the one I have read and which doesn't answer my problem.
So, again, is there a way to show server side validation in the editing form in ExternalFormTemplate mode, without using separate ajax validation callback (this means that when I try to create/update an item, I receive all the errors in the case of failure, see example in the original question), and on the same editing form.
Perhaps it could be done by preventing closing the editing form in the case of server validation errors, or some other mechanism.
Thanks, Tom
|
<script>
function failure(args) {
$("#" + this._id + "_externalEdit").css("display", "block");
}
</script> |
This seems to work OK.
Cheers, Tom
- 5 Replies
- 2 Participants
-
TT Tomislav Tustonic
- Mar 18, 2018 10:46 PM UTC
- Mar 22, 2018 12:53 PM UTC