我我的表格上顯示錯誤與使用如何指定數據標註錯誤的順序Html.ValidationSummary
<%= 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.
從哪裏會寫一個幫手來確定訂單?我在System.ComponentModel中唯一可以找到的是PropertyChangedEventManager類,但我不認爲這是實現它的方法。 – 2010-12-24 17:16:23
當我在我的編輯模型(沒有父母)上運行此示例代碼時,我得到一個PropertyInfo數組,其中包含像System.String Name這樣的項目,但沒有公共方法。 – empty 2015-01-07 18:57:04