【发布时间】:2023-03-28 01:56:02
【问题描述】:
我有一个 RadioButtonList 有两个选项:完整和部分。默认选择是完整的。
<asp:RadioButtonList ID="RadioButtonList1" runat="server">
<asp:ListItem Selected="True">Full </asp:ListItem>
<asp:ListItem>Partial</asp:ListItem>
</asp:RadioButtonList>
我还有一个 jquery 函数,它可以在选择部分时隐藏某些元素,并在选择完整时重新出现。
$(document).ready(function () {
$('#<%=RadioButtonList1.ClientID %>').change(function() {
if($('#<%=RadioButtonList1.ClientID %> input:checked').val() == 'Partial') {
$("#ddlLabel1").hide();
$("#DropDownList1").hide();
} else {
$("#ddlLabel1").show();
$("#DropDownList1").show();
}
});
});
当点击比较按钮时,这会导致隐藏的元素重新出现,但部分元素将保持选中状态。 This is a problem because these hidden elements should never be shown when partial is selected.
我的问题是:当单击比较按钮时,如何将单选按钮列表的值重置为完整?我知道有RadioButtonList1.ClearSelection(); 但我不想清除它,我想重置它。有什么建议吗?
【问题讨论】:
-
查看
SelectedIndex属性。
标签: jquery asp.net radiobuttonlist