0

我的网页上有两个radio buttons和两个,当广播按钮1检查更改并隐藏面板2时panels,我想show面板1,同样,当播放按钮2检查更改并隐藏面板1时,需要显示面板2。

这就是我没有成功的方式

这是我的单选按钮:

<asp:RadioButton ID="RadioButton1" runat="server" Text="Text" ForeColor="White" GroupName="selection" OnCheckedChanged="RadioButton1_CheckedChanged"/>

<asp:RadioButton ID="RadioButton2" runat="server" Text="Image" ForeColor="White" GroupName="selection" OnCheckedChanged="RadioButton2_CheckedChanged"/>

这是 RadioButton1_CheckedChanged:

If RadioButton1.Checked = True Then
            RadioButton2.Checked = False
            Panel1.Visible = True
            Panel2.Visible = False
 End If

这是 RadioButton2_CheckedChanged:

 If RadioButton2.Checked = True Then
            RadioButton1.Checked = False
            Panel1.Visible = False
            Panel2.Visible = True
 End If
4

1 回答 1

2

您需要将autopostback单选按钮设置为 true。 AutoPostback="True"将其包含在您的单选按钮标签中,您应该一切顺利。对您的代码进行简单的调试会告诉您这两个事件都不是用您当前的代码调用的。

于 2012-02-07T16:35:30.440 回答