Thursday, 20 February 2014

JQuery:Check Uncheck all CheckBoxes in ASP.Net CheckBoxList control

Hi Friends,in this article i will explain about Check Uncheck all CheckBoxes in ASP.Net CheckBoxList control.
<html xmlns="">
<head runat="server">
    <title>JQuery:Check Uncheck all CheckBoxes in ASP.Net CheckBoxList control  </title>
    <script src="../Scripts/jquery-1.7.1.min.js" type="text/javascript"></script>
    <script type="text/javascript">
        $(document).ready(function () {
            $("#ChklstEmpDetailsSelectAll").click(function () {
                if ($(this).is(":checked")) {
                    $("#ChklstEmpDetails input").attr("checked", "checked");
                } else {
                    $("#ChklstEmpDetails input").removeAttr("checked");
            $("#ChklstEmpDetails input").click(function () {
                if ($("[id*=ChklstEmpDetails] input:checked").length == $("[id*=ChklstEmpDetails] input").length) {
                    $("[id*=ChklstEmpDetailsSelectAll]").attr("checked", "checked");
                } else {
    <form id="form1" runat="server">
        <input type="checkbox" id="ChklstEmpDetailsSelectAll" runat="server" />Select All
        <asp:CheckBoxList ID="ChklstEmpDetails" runat="server">
            <asp:ListItem Text="ID" />
            <asp:ListItem Text="Name" />
            <asp:ListItem Text="Designation" />
            <asp:ListItem Text="Nationality" />
            <asp:ListItem Text="Department" />
            <asp:ListItem Text="DOB" />
            <asp:ListItem Text="DOJ" />
The output of the above page as shown in the below figure.If we check Select All checkbox then all checkboxes checked automatically and viceversa.If you deselect any one checkbox  checkbox then Select All deselect.

"If you like my blog or articles, you can appreciate by leaving your comments or Liking my Facebook pageAspdotnet-kishore, following on Google+ Aspdotnet-Kishore, Twitter  on AspdotnetKishore, Linked in Aspdotnet-Kishore, stumbling my posts on stumble upon and subscribing on  RSSfeed Aspdotnet-Kishore for free updates directly to your Email inbox . Watch my blog  for more articles."

No comments:

Post a Comment

© 2012-2018 All Rights Reserved.
The content is copyrighted to Kishore and may not be reproduced on other websites without permission from the owner.