Net validating checkbox

Here is the code: Creating the dummy text box and the custom validation control: // add dummy text box just for passing to validation function Text Box txt Dummy = new Text Box(); txt Dummy.

If the checkbox is checked, then the value of checkbox will be passed on the submission of the form. You can validate the value of a checkbox only after the form is being submitted.

net validating checkbox-51net validating checkbox-75

The problem was that I needed a way to know which control to validate. Error Message = "You must select at least one value! Server Validate = new Server Validate Event Handler(Validate Checkbox); val Check.

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

The solution was to hide it by setting its "display" attribute to "none". To String(); // chk is the checkboxlist to validate txt Dummy. If you forget to make a selection from a check box group, you are prompted to make a selection from appropriate check boxes from that group.* In this example there are tow error message types used to indicate the error. This also have a problem i.e for the first time the confirm box is not showing and if once i check the check-box and click on button confirm box is displayed.If i un check it and click on the button the same confirm message is getting displayed instead of alert box. i want to give validation if the checkbox is not selected that it prompt msg "select checkbox first" and2)validation tht i want user to select maximum one check box from gridview ? Height="155px" Width="827px" Use Accessible Header="False" On Selected Index Changed="gv Existing Incident_Selected Index Changed" Fore Color="#333333" On Row Data Bound="gv Existing Incident_Row Data Bound" Font-Bold="True" Font-Strikeout="False" now i want to give validation on particular textbox event...i hav 1 textbox and radiobuttonlist..i want to give validation like if textbox in not empty it has some value and user is not selecting anything in radiobuttonlist and clickng on submitbutton at tht time i want to prompt msg like select radiobutton..

Tags: , ,