使用单选按钮 SelectedIndexChanged 触发 updatePanel
我有一个单选按钮列表(带有 2 个 rdb)和一个检查列表(7 个 ckb)。我希望仅当用户选择选中第二个单选按钮时才显示复选框列表。
我以前从未使用过 AJAX。
我的实际代码(是的,它们在表格内):
<td>
<asp:Label ID="Label7" runat="server" Font-Bold="True">Frequency</asp:Label>
<table>
<tr>
<td>
<asp:RadioButtonList ID="rdbDaysList" runat="server" AutoPostBack="True" OnSelectedIndexChanged="rdbDaysList_SelectedIndexChanged"
RepeatColumns="2" CausesValidation="True">
<asp:ListItem>Daily</asp:ListItem>
<asp:ListItem>Weekly</asp:ListItem>
</asp:RadioButtonList>
</td>
</tr>
<tr>
<td class="style3">
<asp:CheckBoxList ID="ckbList" runat="server" Visible="false" RepeatColumns="5" RepeatDirection="Horizontal">
<asp:ListItem>Monday</asp:ListItem>
<asp:ListItem>Tuesday</asp:ListItem>
<asp:ListItem>Wednesday</asp:ListItem>
<asp:ListItem>Thursday</asp:ListItem>
<asp:ListItem>Friday</asp:ListItem>
<asp:ListItem>Saturday</asp:ListItem>
<asp:ListItem>Sunday</asp:ListItem>
</asp:CheckBoxList>
</td>
</tr>
</table>
</td>
提前致谢!
I have a radiobutton list (With 2 rdb) and a check list (7 ckb). I would like the checkbox list appears only when the user selects the second radio button is checked.
I never used AJAX before.
My actual code (yes, they are inside a table):
<td>
<asp:Label ID="Label7" runat="server" Font-Bold="True">Frequency</asp:Label>
<table>
<tr>
<td>
<asp:RadioButtonList ID="rdbDaysList" runat="server" AutoPostBack="True" OnSelectedIndexChanged="rdbDaysList_SelectedIndexChanged"
RepeatColumns="2" CausesValidation="True">
<asp:ListItem>Daily</asp:ListItem>
<asp:ListItem>Weekly</asp:ListItem>
</asp:RadioButtonList>
</td>
</tr>
<tr>
<td class="style3">
<asp:CheckBoxList ID="ckbList" runat="server" Visible="false" RepeatColumns="5" RepeatDirection="Horizontal">
<asp:ListItem>Monday</asp:ListItem>
<asp:ListItem>Tuesday</asp:ListItem>
<asp:ListItem>Wednesday</asp:ListItem>
<asp:ListItem>Thursday</asp:ListItem>
<asp:ListItem>Friday</asp:ListItem>
<asp:ListItem>Saturday</asp:ListItem>
<asp:ListItem>Sunday</asp:ListItem>
</asp:CheckBoxList>
</td>
</tr>
</table>
</td>
Thanks in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
确保 RadioButtonList autoPostback = true
make sure the RadioButtonList autoPostback = true
您需要使用 UpdatePanel 控件包围单选按钮和复选框列表。然后在单选按钮控件的 OnSelectIndexChanged 事件中,将复选框列表的 Visible 属性设置为 true。
You'll need to surround the radion button and check box list with an UpdatePanel control. Then in the OnSelectIndexChanged event on the radio button control, set the Visible property of then check box list to true.