日期:2014-05-17  浏览次数:20538 次

ASP.NET repeater的全选 反选?
请教大家一个问题?repeater全选反选,怎么通过前台js 实现?后台搞会刷新,不好用

<asp:Repeater ID="Repeater1" runat="server">
  <HeaderTemplate><table width="500" border="1" cellpadding="1" ><tr><td>删除</td><td>姓名</td><td>密码</td></tr></HeaderTemplate>
  <ItemTemplate><tr><td><asp:CheckBox ID="cbx" runat="server" BorderStyle="Groove" /></td><td><%# Eval("name") %></td><td><%# Eval("pass") %></td></tr></ItemTemplate>
  <FooterTemplate></table></FooterTemplate>
  </asp:Repeater>
  <asp:Button ID="Button1" runat="server" Text="批量删除" />
  &nbsp;
  <asp:Button ID="Button2" runat="server" Height="27px" Text="全选" Width="73px" OnClientClick="" />

------解决方案--------------------
C# code

        function checkAll() {
            var checkboxs = document.getElementById("Repeater1").getElementsByTagName("input");
            for (var i = 0; i < checkboxs.length; i++) {
                if (checkboxs[i].type == 'checkbox') {
                    checkboxs[i].cheched = true;
                }
            }
        }