添加一个模型状态:
ModelState.Add("IamKey", new ModelState { Value = new ValueProviderResult("", "HelloKey,IamValue", System.Globalization.CultureInfo.CurrentUICulture) });
清除一个模型错误:
ModelState["Item"].Errors.Clear();
自定义模型信息:
ModelState["hello"].Value = new ValueProviderResult("a", m.Name, CultureInfo.CurrentCulture); ModelState.AddModelError("hello", "should be \"a\"");
ASP.NET MVC ModelState,布布扣,bubuko.com
原文:http://www.cnblogs.com/ibgo/p/3914724.html