我正在ASP.NET MVC 3中工作,我遇到了一個奇怪的問題。我收到了一個複選框,用戶必須檢查它是否已經閱讀並繼續。如果他們不檢查,他們不能繼續。這一切都有效。Html.CheckBoxFor()導致驗證消息消失
如果他們沒有選中該框,驗證消息將根據需要彈出,並且標籤顯示爲紅色。但是,當我選中該框時,標籤將隨驗證消息一起消失。什麼會造成這種情況?我希望標籤保持原樣。 ;)這裏的視圖代碼:
@section StepContent
{
<div>
@Html.LabelFor(m => m.ApplicantAgreesToDisclosure)
@Html.CheckBoxFor(m => m.ApplicantAgreesToDisclosure)
@Html.ValidationMessageFor(m => m.ApplicantAgreesToDisclosure, "Please indicate that you agree to the disclosure.")
</div>
}
和模型代碼:
[DisplayName("I have read and accept the above disclosure")]
[ESignatureRequiredValidation(ErrorMessage = "Please indicate that you agree to the disclosure.")]
public bool ApplicantAgreesToDisclosure { get; set; }
因爲驗證在盒子檢查時通過? –
是的,但標籤不應該留下? –
您的代碼隱藏了標籤。找到它。處置它;) –