Radio buttons clear check when you click again


I have a set of three radio buttons and they have mutual exclusion in them, as I implemented group name property, but the problem is, in the initial stage, none of the radio button is selected,

But when I select any of the radio button, then I cannot deselect the same, although mutual exclusion is in progress, but I want them to deselect as well.

My code aspx is:

<asp:RadioButton ID="AChk" runat="server" CssClass="itemRightAlign" GroupName="A"/>
<asp:RadioButton ID="DChk" runat="server" CssClass="itemRightAlign" GroupName="A"/>
<asp:RadioButton ID="WChk" runat="server" CssClass="itemRightAlign" GroupName="A"/>

You have both a code problem and a misunderstanding.

The misunderstanding is about how the mutual exclusion radio buttons work (or are supposed to work) (or are expected by the users to work).

The code problem is that in a mutually exclusion radio buttons group you need to initially select one of them.

So, I believe there are two ways of solving the problem:

  1. Keep the radio buttons groud. Add a "none" button to the set, so that it works as if none of the other three are selected. And initially select this "none" button.

  2. change the radio buttons to check boxes, so the user might select and deselect each of them. Then implement your own exclusion logic. I don't recommend this one.