开发者

Double mouse-click event for RadioButtonList

I have a RadioButtonList with several ListItems. As user click before thinking they select an option even if they don't need开发者_C百科 it here.

Is it possible to set the SelectedIndex of a RadioButtonList to -1 by double-clicking on the list with the mouse?

asp.net c# webapplication


The following jquery script will uncheck the selected radio button item when double clicking on it.

<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>

You might also want to consider using MutuallyExclusiveCheckBox of Ajax Control Toolkit

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜