I have two radio buttons in ASP.Net as follows:
<dx:ASPxRadioButton ID="RB_Type" runat="server" AutoPostBack="true" Theme="Office365" Text="Type of media" Font-Size="Medium"></dx:ASPxRadioButton>
<dx:ASPxRadioButton ID="RB_Date" runat="server" Theme="Office365" AutoPostBack="true" Text="Date" Font-Size="Medium" ClientInstanceName="RB_Date"></dx:ASPxRadioButton>
For example I want that when I select #RB_Type the #RB_Date radiobutton is unchecked and then if I click on #RB_Date the #RB_Type button is unchecked.
To do this I have the following code in VB.NET:
If RB_Type.Checked Then
RB_Date.Checked = False
ElseIf RB_Date.Checked Then
RB_Type.Checked=False
EndIf
But at runtime if I select RB_Type and then click on RB_Date then RB_Type will remain selected and RB_Date will be unchecked.
I would like to find a solution, thanks in advance.
You don't need any code at all. You should be setting the GroupName
property of your RadioButtons
to the same value for those controls that you want to work as a group. That group will then be inherently mutually-exclusive, i.e. checking one in the group will automatically uncheck any others.