首页 > 代码库 > ASP.NET MVC ModelState

ASP.NET MVC ModelState

添加一个模型状态:

ModelState.Add("IamKey", new ModelState {                 Value = new ValueProviderResult("", "HelloKey,IamValue", System.Globalization.CultureInfo.CurrentUICulture) });

清除一个模型错误:

ModelState["Item"].Errors.Clear();

 自定义模型信息:

ModelState["hello"].Value = http://www.mamicode.com/new ValueProviderResult("a", m.Name, CultureInfo.CurrentCulture);ModelState.AddModelError("hello", "should be \"a\"");