So I’ve got three RadioButtons, They’re not in a RadioButtonList because I need to add some textboxes next to each of them.
I’ve added a GroupName, and on the front end they behave as expected. ONLY ONE appears checked at a time.
However in the code, if I do:
RadioButton1.Checked = true;
RadioButton2.Checked = true;
RadioButton3.Checked = true;
I would expect only the last one, RadioButton3, to be checked, because they all belong to the same group. This is not the case. All three evaluate to true…. how can that be?
I have to set them explicitly to false… am I missing something?
I think this is the correct behavior although it is not what you might expect.
Consider that a
RadioButtonis just aCheckBoxwith some extended functionality to automatically to give that exclusive checking functionality. In the background it is still a checkbox though. See the hierarchy from MSDN:The output has all items with the attribute
checked="checked"output for theinputoftype="radio". Eg:From the
Checkedproperty documenation:So the
Checkedproperty acts just like theCheckBoxversion with no functionality included to look for other controls in the same group and remove them which makes sense since it is a singular control.