I show errors in my form with
<%= Html.ValidationSummary("Please review the errors below") %>
My domain object is inherited from the base class, and I find that the data annotation properties of the base class are displayed at the bottom of the list. This is contrary to the order in which they appear in my form.
Is there a way to indicate in which order the errors should be displayed?
Example:
public class ClassA { [Required]public string AProperty; } public class ClassB : ClassA { [Required]public string BProperty; }
My form (strongly typed class view):
AProperty: <%= Html.TextBoxFor(m => m.AProperty) %> BProperty: <%= Html.TextBoxFor(m => m.BProperty) %>
Validation errors are displayed as:
The BProperty is required. The AProperty is required.
source share