0

I'm working in ASP.NET MVC 3 and I'm running into an odd problem. I got a checkbox set up so the user must check it to indicate they have read the disclosure and continue. They cannot continue if they don't check this. That all works.

If they do not check the box, the validation message pops up as required, and the label is displayed in red. However, when I check the box, the label disappears with the validation message. What would cause this? I'd like the label to stay put. ;) Here's the code in the view:

    @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>

    }

And the code in the Model:

    [DisplayName("I have read and accept the above disclosure")]
    [ESignatureRequiredValidation(ErrorMessage = "Please indicate that you agree to the disclosure.")]
    public bool ApplicantAgreesToDisclosure { get; set; }
3
  • Because the validation passes when the box is checked?
    – Forty-Two
    Commented Sep 7, 2012 at 14:49
  • Yes, but shouldn't the label stay? Commented Sep 7, 2012 at 15:34
  • You have code somewhere that's hiding the label. Find it. Dispose of it;)
    – Forty-Two
    Commented Sep 7, 2012 at 16:03

2 Answers 2

1

As it turns out, there's some inline CSS causing the element to disappear. Using FireBug with Firefox and clicking on the disappearing element showed that my CSS was being overridden somewhere else. It's not a problem in my MVC code. I've marked my CSS as "!important" (meaning my bit of CSS is "important") as a temporary fix until I can find the inline code.

0

This is because once the checkbox is checked it passes validation. Why do you believe this to be a problem? What behavior are you expecting?

3
  • The validation message can disappear for all I care. I just want the label to stay. ;) Commented Sep 7, 2012 at 15:19
  • ahh, sorry. misunderstood. Use FireBug to determine if it's just a css change or if the label has actually been removed. Without seeing your page it's hard to guess.
    – Jeff
    Commented Sep 7, 2012 at 17:07
  • Okay, FireBug is showing that there is some mysterious inline css out there causing it to disappear. I have yet to find it. Some other guys write most of this code and I don't know my way around it fully yet. Anyway, thanks! Commented Sep 7, 2012 at 20:16

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.