Hi Friends,in this article i will
explain about Check Uncheck all CheckBoxes in ASP.Net CheckBoxList control.
I already explained in the previous
articles about SQL Server 2008 XML input parameter to stored procedure and insert XML
data to Table,How to get selected text of
CheckBoxList and align CheckBoxList Horizontal in ASP.NET using C#/VB.NET,SQL SERVER – Simple Example of Cursor.
ASP.NET:
<html xmlns="http://www.w3.org/1999/xhtml">
<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 {
$("[id*=ChklstEmpDetailsSelectAll]").removeAttr("checked");
}
});
});
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<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"
/>
</asp:CheckBoxList>
</div>
</form>
</body>
</html>
|
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
"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