Radio button checked changed event in asp.net

2019-07-17 20:29发布

I have 2 radio buttons on a simple web page and If I click one of them the other should be false(i.e checked=false) but it's not working Can anyone point me the mistake I'm doing.I knew it's a silly one but I need to know what's going on?

Here are the radio buttons:

<asp:RadioButton ID="Rb1" runat="server" Text=""/>

<asp:RadioButton ID="Rb2" runat="server" Text=""/>

Onchecked changed event:

Protected Sub Rb1_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Rb1.CheckedChanged
    Rb2.Checked = False
End Sub

Protected Sub Rb2_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Rb2.CheckedChanged
    Rb1.Checked = False
End Sub

1条回答
混吃等死
2楼-- · 2019-07-17 20:30

You have to set GroupName property and AutoPostBack=True.

查看更多
登录 后发表回答