Asp net validating a checkboxlist control
It saves a great deal of time in hand coding Java Script validation.
Unfortunately, validation controls donâ€™t work with the Check Box or Check Box List controls.
will point the validator at the property to validate against.
The Check Box, Radio Button, Html Input Check Box and Html Input Radio Button lack this attribute, accordingly, any standard validation control will throw an exception Finally, if you like the article and find the control useful, then please Kick It (using the button below) and it would be kind of you to leave a comment. I have also created the Multiple Fields Validator validator control to tackle the problem of validating multiple controls.
These checkbox lists are created dynamically at runtime. Add(txt Dummy); // add custom validation control Custom Validator val Check = new Custom Validator(); val Check.
This is what I did: I created a dummy textbox and put the ID of the checkboxlist as the value inside the text box.
I found many solutions from searching on the Internet, but most of them didnâ€™t work very well, if at all, and very few were designed for use with an asp: Check Box.
I sent the textbox as the control to validate, and then got the ID of my "real" control to validate from the value that was sent to the validation function, and used it to find my checkbox list and perform the validation checks.
But of course I didn't want the user to see the dummy text box. When I did that, the validation method was never called. NET does not perform validation for a control whose visibility is false.
Hi Rahul, I guess you want to show a Requierd Field Validator for ASP Check Box List.
But there is no field in the Check Box List to fill, so Requierd Field Validator doesn't work for this Control.