添加一个模型状态:

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\"");

 

相关文章:

  • 2021-05-31
  • 2022-12-23
  • 2022-12-23
  • 2021-10-27
  • 2022-12-23
猜你喜欢
  • 2021-11-18
  • 2021-05-22
  • 2022-12-23
  • 2021-08-28
  • 2021-12-28
  • 2022-01-07
相关资源
相似解决方案