Created
June 4, 2018 17:20
-
-
Save rschiefer/ee266e9ab38ca5ee279134e14c268a41 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
protected JsonResult RemoteJsonResponseForProperty(string property = null) | |
{ | |
object response; | |
if (string.IsNullOrWhiteSpace(property)) | |
{ | |
property = System.Web.HttpContext.Current.Request.QueryString.Keys[0]; | |
} | |
if (ModelState.ContainsKey(property) && ModelState[property].Errors.Any()) | |
{ | |
response = string.Join(". ", ModelState[property].Errors.Select(e => e.ErrorMessage)); | |
} | |
else | |
{ | |
response = true; | |
} | |
return Json(response, JsonRequestBehavior.AllowGet); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment