I have the following code in my controller after the user has submitted the form, but if the verification fails (_applicationValidator.Validate), I usually reload the Edit view, but in this case I want the dialog to be open and just show these errors inside the dialog box.
Controller Code:
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult Update(ApplicationUpdater applicationUpdater_)
{
if (_applicationValidator.Validate(applicationUpdater_, ModelState, ValueProvider))
{
_repo.UpdateApplication(applicationUpdater_);
ApplicationsViewModel vm = new ApplicationsViewModel();
vm.Applications = _repo.GetApplications();
return View("Index", vm);
}
else
{
ApplicationViewModel vm = GetApplicationVM();
return View("Edit", vm);
}
}
View code ( jQuery )
$(".showEditPopup").click(function() {
$.post("Applications/ShowEdit",
{ recnum: $(this).parents('tr:first').attr("recnum") },
function(htmlResult) {
$("#EditUserControlDiv").remove();
$("#container").append(htmlResult);
$("#container select[multiple]").asmSelect();
$("#EditUserControlDiv").dialog(
{
height: 675,
width: 650,
modal: true
}
);
}
);
});
leora source
share