How to read modelstate errors when returned by Json?
Posted
by user281180
on Stack Overflow
See other posts from Stack Overflow
or by user281180
Published on 2010-05-11T05:38:46Z
Indexed on
2010/05/11
5:44 UTC
Read the original article
Hit count: 210
asp.net-mvc
How can I display modelstate errors returned by Json ?
I want to do somthing like that...
if (!ValidateLogOn(Name, currentPassword))
{
ModelState.AddModelError("_FORM", "Username or password is incorrect.");
//Return a json object to the javascript
return Json(new { ModelState });
}
What must be my code in the view to read the modelstate errors and display them?
My actual code in the view is as follows to read the Json values:
function createCategoryComplete(e) {
var obj = e.get_object();
alert(obj.Values);
}
© Stack Overflow or respective owner