Radio button checked changed event in asp.net

柔情痞子 提交于 2019-12-24 01:09:50

问题


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:


You have to set GroupName property and AutoPostBack=True.



来源:https://stackoverflow.com/questions/7859959/radio-button-checked-changed-event-in-asp-net

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!