我已经安装了 Scott 的 Kirkland DataAnnotationsExtensions。
在我的模型中,我有:
[Numeric]
public double expectedcost { get; set; }
在我看来:
@Html.EditorFor(model => model.expectedcost)
现在,当页面尝试呈现时,出现以下错误:
Validation type names in unobtrusive client validation rules must be unique. The following validation type was seen more than once: number
有什么想法为什么我会出错吗?
最佳答案
快速答案是简单地删除属性
[Numeric]
更长的解释是,根据设计,验证已经添加了一个 data-val-number,因为它是 double 类型。通过添加数字,您将重复验证。
这有效:
[Numeric]
public string expectedcost { get; set; }
因为变量是字符串类型并且您正在添加数字属性。
希望这可以帮助
关于asp.net-mvc - MVC3 DataAnnotationsExtensions 错误使用数字属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5416509/