-2

I want to do on button click check/ucheck all checkbox client side. my code is

<asp:Button ID="btn_select" runat="server" Text="Select All Checkbox" UseSubmitBehavior="false"></asp:Button>
<telerik:RadListView ID="RadListView_Permission" runat="server" AllowCustomPaging="true" AllowPaging="True" onitemdatabound="RadListView_Permission_ItemDataBound">
    <ItemTemplate>
        <div style="border:1px solid gray;">
            <table width="100%">
                <tr>
                    <td width="5%"></td>
                    <td class="LabelWidth">
                        <div>
                            <asp:Label ID="Label4" runat="server" Text='<%# (DataBinder.Eval(Container.DataItem, "PermissionItemName")) %>'></asp:Label>
                        </div>
                    </td>
                    <td style="margin:2%; width:70%;">
                        <%-- <div class="checkbox-list">
                            <label class="checkbox-inline">--%> <span style=" margin:2%;width:50%; text-align:left; "><asp:CheckBoxList RepeatDirection="Horizontal" AutoPostBack="false" CellPadding="5" CellSpacing="7"  RepeatLayout="Table"  ID="Listbox_Permission" runat="server" DataTextField="PermissionOperationName" DataValueField="PermissionItemOpearationId"  CssClass="checkbox-inline checkbox-list" >    </asp:CheckBoxList></span>

                                <%-- </label>
        </div>--%></td>
        </tr>
        </table>
        </div>
    </ItemTemplate>
</telerik:RadListView>
Cœur
  • 37,241
  • 25
  • 195
  • 267
user3167877
  • 11
  • 1
  • 4

1 Answers1

0

Do it like this:

<input type="button" class="check" value="check all" />
<input type="checkbox" class="cb-element" /> Checkbox  1
<input type="checkbox" class="cb-element" /> Checkbox  2
<input type="checkbox" class="cb-element" /> Checkbox  3

$('.check:button').toggle(function(){
    $('input:checkbox').attr('checked','checked');
    $(this).val('uncheck all')
},function(){
    $('input:checkbox').removeAttr('checked');
    $(this).val('check all');        
})

Taken from here: jquery check uncheck all checkboxes with a button

Fiddle

Community
  • 1
  • 1
James Hibbard
  • 16,490
  • 14
  • 62
  • 74