User265788195 posted
Hi,
I am getting list of Model Errors in string list.
The want to store the key value attached to the model error.
Lets say the ErrorMessage is "FirstName is required", I want to know it by some key
so that I can place the focus on FirstName input box.
So I wnat to pass that key as well thru Json here.
var errorList = new List<string>();
foreach (ModelState modelState in ViewData.ModelState.Values)
{
foreach (ModelError error in modelState.Errors)
{
errorList.Add(error.ErrorMessage);
}
}
return Json(new { personId = -1, errorMessage = errorList.ToList() });