c# mvc modelstate
2021-02-07 13:15
标签:value request model var name color lis 添加 list model里面添加字段 c# mvc modelstate 标签:value request model var name color lis 添加 list 原文地址:https://www.cnblogs.com/LiuFengH/p/11386780.html [Required]
[DisplayName("112")]
var errs = new Liststring>();
if(ModelState.IsValid)
return Json(save, JsonRequestBehavior.AllowGet);
else
foreach (var state in ModelState)
{
foreach (var err in state.Value.Errors)
{
errs.Add(err.ErrorMessage);//把错误添加到数组里
}
}
return Json(string.Join(",",errs), JsonRequestBehavior.AllowGet);