【问题标题】:Double mouse-click event for RadioButtonListRadioButtonList 的双击鼠标事件
【发布时间】:2023-04-04 10:04:01
【问题描述】:

我有一个带有多个 ListItem 的 RadioButtonList。当用户在考虑之前点击他们会选择一个选项,即使他们在这里不需要它。

是否可以通过用鼠标双击列表来将 RadioButtonList 的 SelectedIndex 设置为 -1?

asp.net c# webapplication

【问题讨论】:

  • 您希望用户单击单选按钮后,他可以撤消选择吗?
  • @bemused 我动态创建 Rbls 并在一个表单上有多个 rbls。我可以结合一个下拉菜单,让用户选择需要清除的 rbl,但如果可以双击,那将是一种更简单的方法。
  • @muhammad 其实我想在点击时撤消选择,这样用户就不需要进一步的操作了
  • 所以当您从下拉列表中选择某个值时,您希望该用户不再从列表中选择单选按钮?
  • 我只是说这可能是来自困惑帖子的反应。如果以另一种方式更容易,我更喜欢这种方式,比如双击 rbl

标签: c# asp.net radiobuttonlist


【解决方案1】:

以下 jquery 脚本将在双击选中的单选按钮项时取消选中它。

<asp:RadioButtonList ID="RadioButtonList1" runat="server">
    <asp:ListItem Text="One" Value="1"></asp:ListItem>
    <asp:ListItem Text="Two" Value="2"></asp:ListItem>
    <asp:ListItem Text="Three" Value="3"></asp:ListItem>
</asp:RadioButtonList>
<script type="text/javascript" src="Scripts/jquery-1.4.2-vsdoc.js"></script>
<script type="text/javascript">            
    $(document).ready(function () {
        $('#<%= RadioButtonList1.ClientID %>').dblclick(function () {
            $('#<%= RadioButtonList1.ClientID %> input:radio:checked').each(function () {
                $(this).attr('checked', false);
            });
        });
    });          
</script>

您可能还想考虑使用MutuallyExclusiveCheckBox of Ajax Control Toolkit

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-02-09
    • 2012-01-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-01-12
    • 2012-12-24
    相关资源
    最近更新 更多