If you see a problem on the internet, try to get the checkbox value. The technology is not very difficult, but you have time to do exercises.
Create a webpage:
Write the click event. When the checkbox is selected, the text value of the checkbox is obtained. Otherwise, the textbox value is cleared:
Real-time Demonstration:
What if the requirement is not to directly access the checkbox, but to access the checkbox in the DIV label? To try:
In fact, after adding the DIV tag control, you can still obtain the checkbox value using the above method. However, we want to get it from the DIV control. How can we implement it?
You can cycle all controls in the DIV control. because there may be other controls in the DIV control, you must determine whether the same is a checkbox control:
In the preceding example, the checkbox control is only placed in a div control. If it is stored in a deep control, do we need several foreach (control CTL in div1.controls) or is the findcontrol () method used to find the checkbox?
You don't have to worry about this. There is a way for you to quickly find the target, reference here "not using the findcontrol method to find deep nested controls" http://www.cnblogs.com/insus/archive/2012/09/27/2705388.html its upgrade article "not using the findcontrol method to find deep nested controls ver2" http://www.cnblogs.com/insus/archive/2012/10/07/2713568.html
Get the text value of the checkbox