Validating Checkboxes

Topics: Validation Application Block
May 8, 2008 at 7:32 PM
Hello,

it is possible to validate a checkbox for checking using the proxyvalidator and the microsoft enterprise application validation block? Because on the one hand there is no bool validator or something similar which fit to a checkbox and on the other hand the proxyvalidator raises an error saying that the control cannot be validated.

regards
Tom (negPoint;CSD)
May 12, 2008 at 2:39 PM
Edited May 12, 2008 at 2:56 PM
Hi Tom.
I don't know if I got your question correct, but maybe this code sample will help:
I create a new RangeValidator and then use it to validate my checkbox control (checkBox1)

RangeValidator rv = new RangeValidator(false, RangeBoundaryType.Exclusive, true, RangeBoundaryType.Inclusive, "CheckBox Error", false);
ValidationResults vr = new ValidationResults(); 
rv
.Validate(checkBox1.Checked, vr);

richTextBox1
.Text = "Testresult:";

foreach (ValidationResult r in vr)
{
    richTextBox1
.Text += "\n" + ":\n" + r.Message + "\n";
}


/Nesse

May 13, 2008 at 11:20 PM
Hi,

Checkboxes cannot be validated with ASP.NET's control validators, including EntLib's PropertyProxyValidator; the CheckBox class lacks the ValidationProperty attribute required for these validators to work.

Fernando



KidSteele wrote:
Hello,

it is possible to validate a checkbox for checking using the proxyvalidator and the microsoft enterprise application validation block? Because on the one hand there is no bool validator or something similar which fit to a checkbox and on the other hand the proxyvalidator raises an error saying that the control cannot be validated.

regards
Tom (negPoint;CSD)