我正在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; }
因为验证在盒子检查时通过? –
是的,但标签不应该留下? –
您的代码隐藏了标签。找到它。处置它;) –