【发布时间】:2017-04-25 18:13:36
【问题描述】:
我有一个列表,我正在我的自定义验证属性中进行检查。在我的视图中列出这样的渲染
<input type="check" value="Bath">
<input type="check" value="Food">
我的自定义验证器是...
public class MyAttribute: ValidationAttribute
{
// some logic and then
// Get Data from some webservice
// Make sure CERTAIN checkboxes are selected
// If Bath was NOT checked then
return new ValidationResult("Bath is Required")
// If Food was NOT checked then
return new ValidationResult("Food is Required")
}
现在这工作正常,我可以在我的视图上显示错误消息“Some Error”,但是我的问题是我想在周围显示 RED ERROR BOX需要检查的复选框。目前我只是在我的视图上显示一个错误消息字符串。如果用户能看到需要什么,那就太好了。
【问题讨论】:
标签: asp.net-mvc