我正在使用以下方式在表单上显示错误:
<%= Html.ValidationSummary("Please review the errors below") %>
我的领域对象继承自一个基类,我发现基类的数据注释属性被显示在列表底部。这与它们在表单中出现的顺序相反。
有没有办法指定错误显示的顺序?
例如:
public class ClassA { [Required]public string AProperty; }
public class ClassB : ClassA { [Required]public string BProperty; }
我的表格(ClassB的强类型视图):
AProperty: <%= Html.TextBoxFor(m => m.AProperty) %>
BProperty: <%= Html.TextBoxFor(m => m.BProperty) %>
验证错误会显示为:
The BProperty is required.
The AProperty is required.