zoukankan      html  css  js  c++  java
  • Repeater内RadioButton.GroupName失效

    最近在做项目时遇到要在repeater中显示多个radiobutton并且实现单选功能,于是很自然地就加上了GroupName,但事实是不行的,在repeater中的radiobutton呈现到页面的时候name会自动加上repeater的id、序列ct100和radiobutton的id,这就直接导致为什么GroupName会失效了。我在网上搜了有很多方法,但是都没适用的,比如用<input type=radio>、radiobuttonlist等,但是我既然用了radiobutton,就懒得换了,以下是我的代码实现:

    页面

     1 <table>
     2                             <tr>
     3                                 <asp:Repeater runat="server" ID="repbgs">
     4                                     <ItemTemplate>
     5                                         <td>
     6                                             <asp:RadioButton runat="server"  ID="rdo1" Text='<%# Eval("name") %>' />
     7                                         </td>
     8                                     </ItemTemplate>
     9                                 </asp:Repeater>
    10                             </tr>
    11                         </table>

    后台就一个绑定过程就不展示了,还有就是jQuery

    1 $(':input:radio').click(function () {
    2                 if ($(this).is(':checked')) {
    3                     $(this).is(':checked');
    4 $(this).parents().siblings().children().removeAttr("checked");
    5                 }
    6             });

    以上就是我的简单实现

  • 相关阅读:
    Django中的CSRF
    CentOS 7上快速安装saltstack
    Django中的Form和ModelForm
    Linux下git使用
    django 登录、注册
    django 知识点小结
    django 博客搭建
    django models中字段
    django models中的class meta
    Django Queryset增加manager
  • 原文地址:https://www.cnblogs.com/tony312ws/p/3838314.html
Copyright © 2011-2022 走看看