I’m trying to create an array of checkboxes dynamically and also want to put event to those checkboxes. How can I do this?
For example:
I have a array of checkboxes – Chk1, Chk2.
I want it to work this way: When I check Chk1, I want to disable Chk2, and when Chk1 is unchecked, Chk2 is enable, and vice versa.
Your input is greately appreciated.
Thanks,
P.S.: The code is in VB.NET. Thanks.
Thank you all for the inputs. I really appreciated it. Maybe I wasn’t very clear on my explanation earlier.
Let’s say, I have an array of 6 checkboxes, and I want them to behave in group like this:
-
When Chk1 is checked, Chk2 is disabled (grey out), and when we uncheck Chk1, Chk2 is enabled, and Vice Versa.
-
When Chk3 is checked, Chk4 is disabled, and when we uncheck Chk3, Chk4 is enabled, and Vice Versa.
and so on….
So this is like each pair of checkboxes in the array perform the CheckChanged event upon each other, but not on any other pair. So I think OptionButton is not the case in this situation.
Thanks for any suggestions.
Assuming that it is ASP.Net, have a look at this “strange” example to see how it works(take your array instead of my static creation):
Apart from that i can subscribe Hans’ suggestion to use RadioButtons or at least a CheckBoxList.