This is a migrated thread and some comments may be shown as answers.

Ajax Editing business errors not showing up

2 Answers 55 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Jatin
Top achievements
Rank 1
Jatin asked on 05 Aug 2011, 01:54 AM
Hi,
   I am trying to implement ajax editing (Popup mode) in Telerik Q2 grid. The Model is EntityFramework model which has data annotation for various property validation. After submitting the ajax edit form, if there are any errors related to the Model annotations, these errors show up correctly. However if I use ModelState.AddModelError() add business errors to model, these errors does not show in the grid ajax edit form. Is it possible to display business error message like the ones that are displayed when the TryUpdateModel() fails ?

Here is the simplified code that I am using
<!-- Model Editor Template -->   
 
@Html.ValidationSummary()
    <div class="content">
        @{Html.RenderPartial("_UserEdit");}   
    </div>

//Controller
[GridAction][HttpPost]
public ActionResult _UserUpdate(int id) {
    User user = userManager.FindUser(id);
    if (user != null) {
        if (TryUpdateModel(user)) {
            try {
                userManager.EditUser(user);
            }
            catch (Exception ex) {ModelState.AddModelError("RepositoryException",ex.Message);     //Does not show up
            }
        }
    }
    return View(new GridModel(userManager.GetQueryableUsers()));
}


regards,
Nirvan.

2 Answers, 1 is accepted

Sort by
0
Jatin
Top achievements
Rank 1
answered on 06 Aug 2011, 02:29 AM
That was a silly question. ValidationSummary cannot be used in ajax calls. So then how do we show custom errors in Ajax popup editing ?

regards,
Nirvan.
0
Wade
Top achievements
Rank 1
answered on 12 Dec 2011, 09:58 PM
Any response on this.  I am having the same issue.  Sometimes I need to display a field level error message in the pop up which works fine, however if I want to display any sort of error message using @Html.ValidationSummary()  those errors do not get displayed.  Using the code @Html.ValidationSummary does not display the individual field level error messages either. 

Thoughts?
Tags
Grid
Asked by
Jatin
Top achievements
Rank 1
Answers by
Jatin
Top achievements
Rank 1
Wade
Top achievements
Rank 1
Share this question
or