How to create Modal State Errors

2 posts, 0 answers
  1. Meerkat
    Meerkat avatar
    64 posts
    Member since:
    Feb 2007

    Posted 12 Apr 2013 Link to this post

    Hello,
    There seem to be several examples dotted around the place on how to handle Model State errors
    e.g. How do I display model state errors?
    http://docs.kendoui.com/getting-started/using-kendo-with/aspnet-mvc/helpers/grid/faq
    However I cannot find any documentation on how to create the error on the server in the first place.
    Any hint of what needs to replace the comments shown below, would be much appreciated.
    Regards,
    Pete
    [AcceptVerbs(HttpVerbs.Post)]
    public ActionResult Update_User([DataSourceRequest] DataSourceRequest request, UserProfile userprofile)
    {
      if (userprofile != null && ModelState.IsValid)
      {
        if (errorcondition)
        {
          //raise something here that will be picked up by the onError function described above
          //to inform the user that some sort or error occured
        }
      }
      else
      {
        //raise something here that will be picked up by the onError function described above
        //to inform the user that the ModelState.IsValid is Invalid
      }
      return Json(ModelState.ToDataSourceResult());
    }


  2. Vladimir Iliev
    Admin
    Vladimir Iliev avatar
    2194 posts

    Posted 16 Apr 2013 Link to this post

    Hi Pete,

     
    I would suggest to check the "Handling server-side validation errors during pop-up editing" demo in our CodeLibrary which demonstrates how to handle server-side validation errors (add them to the ModelState) and to display the validation message within the edit form.

    Kind Regards,
    Vladimir Iliev
    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Back to Top