我在視圖中添加了驗證消息「CountryId自定義錯誤」。問題是當我最初加載視圖時以及在POST時顯示。如何停止ValidationMessageFor在加載時顯示錯誤消息?
<div class="editor-field">
@Html.DropDownList("CountryId", Model.GetCountries, "Please select", "0")
@Html.ValidationMessageFor(m => m.CountryId, "CountryId custom error")
</div>
我怎樣才能讓它只顯示在POST? 如果我省略驗證消息,則視圖在POST上正常顯示默認錯誤。