Validating checkboxlist asp net control using javascript

Use the Data Text Field and Data Value Field properties to specify which field in the data source to bind to the properties of each list item in the control, respectively.The Check Box List control will now display the information from the data source.I've spent a couple of hours searching for a solution to validating a checkbox, since the Required Field Validator does not work with Checkboxes. Look for "skm Validators - custom validation controls for Check Boxes and Check Box Lists Actually I like to use AJAX for Checkbox validation, if you add the checkboxes inside an Update Panel and then on the server side you can check if they are check or not and update a red label by the checkbox.To the user, looks like works the same way the validation, for you, is just a little bit more magic to write.In this method I just loop through all the items of the Check Box List and if I find one that is selected then I return true.Now we have the validation working on the server after a postback, but it would be nice if we could perform the validation directly on the client when the user toggles the state of the checkboxes.

Below, I am showing a Java Script variable being set, that is for use by the Java Script method.

To accomplish this there is another step to take: inject some client side Java Script in the On Pre Render method.

The Pre Render event is raised just before the control is rendered on the page, so it the best moment to inject some client side functionality into the page.

$(source).parent() will get parent DOM element of the Custom Validator control that fired the Validate CBL function.

And then it finds any table that has an id ending with _Check Box List1.

Search for validating checkboxlist asp net control using javascript:

validating checkboxlist asp net control using javascript-44validating checkboxlist asp net control using javascript-65validating checkboxlist asp net control using javascript-18

I found a 2001 article on how to do that (Building a Check Box List Validator Control) but it doesn't work properly on ASP. So I have to make some small changes to make it work on ASP. First thing you have create a class that inherits from Base Validator In this we check if the control is null and if the control can be cast to a Check Box List.

Leave a Reply

Your email address will not be published. Required fields are marked *

One thought on “validating checkboxlist asp net control using javascript”

  1. In this interview, Blucas talks about working with Katie Holmes and Forest Whitaker on First Daughter, and, of course, the continued support of Buffy fanatics. What happened was, all of this I learned after the fact of course, he could have saved me a lot of stress and agony by not putting me through the audition process. I was going to the meeting and Forest (Whitaker) was going to the meeting as well, and I parked my truck and he was about 20 feet away. We dont feel like we need to feel the pressure of going first.