我已经使用标签助手进行验证摘要
<div asp-validation-summary="ValidationSummary.All" class="text-warning"></div>
但不是预期的The {0} field is required
字符串RequiredAttribute_ValidationError
显示:
<div class="text-warning validation-summary-errors" data-valmsg-summary="true"><ul>
<li>RequiredAttribute_ValidationError</li>
</ul></div>
我需要做些什么来获得预期的The {0} field is required
值?
dnvm输出
Active Version Runtime Architecture OperatingSystem Alias
------ ------- ------- ------------ --------------- -----
1.0.0-beta4 mono linux/osx
1.0.0-beta5-11576 mono linux/osx
1.0.0-beta5-11744 mono linux/osx
1.0.0-beta7 coreclr x64 darwin
1.0.0-beta7 mono linux/osx
1.0.0-beta8 coreclr x64 darwin
* 1.0.0-beta8 mono linux/osx default
1.0.0-rc2-16128 coreclr x64 darwin
1.0.0-rc2-16128 mono linux/osx
答案 0 :(得分:1)
这是单声道的错误。
快速解决方法,指定ErrorMessage
格式:
[Required(ErrorMessage = "The {0} field is required.")]
[Display(Name = "Email")]
public string email { get; set; }
答案 1 :(得分:0)
您是否已将DisplayAttribute添加到所需的视图模型属性中?验证摘要将使用display name属性填充验证错误。
public class ViewModel
{
[Required]
[Display(Name = "Email Address")]
public string Email { get; set; }
}