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 = new ValueProviderResult("a", m.Name, CultureInfo.CurrentCulture);

ModelState.AddModelError("hello", "should be \"a\"");

 

你可能感兴趣的:(asp.net)