I have check box list and a check box, After binding the data to the checkbox, if we select the all checkboxes then the main checkbox gets selected its fine till now but when we unselect any check box in checkbox list and clicks a button then all checkboxes in the checkboxlist getting unchecked.
How to Hold the checked items of the checkbox list even after the post back.
Javascript code
function pageLoad(sender, args)
{ CheckAllProject();
}
function CheckAllProject () {
$("[id*=lbxProjectList]").focus(function () {
if ($("[id*=lbxProjectList] input:checked").length == $("[id*=lbxProjectList] input").length) {
$("[id*=CheckBox1]").attr("checked", "checked");
} else {
$("[id*=CheckBox1]").removeAttr("checked");
}
});
} It Looks like in the following way
Project List:CheckBox Select All Projects
Checkbox 1 Project1
Checkbox 2 Project2
Button Submit

Jaganathan BantheswaranPosted Nov 6, 2014, 7:51 AM
Santosh KumarPosted Nov 6, 2014, 7:29 AM
http://jsfiddle.net/Jaganathan/CfcxL/33/
the event is firing on button click, but for me the after all checkboxes are select then main checkbox need to be checked how i can add the event for the checkbox list which checks all the check boxes got selected.
Jaganathan BantheswaranPosted Nov 6, 2014, 7:22 AM
http://jsfiddle.net/Jaganathan/CfcxL/33/
Santosh KumarPosted Nov 6, 2014, 7:12 AM
Is there any way to add the onclick event to the asp.net checkbox list instead of calling event in pageload event in javascript.
Here is my asp code of the check box list
Jaganathan BantheswaranPosted Nov 6, 2014, 7:01 AM
You can do something like to add a hidden field/session to the page that represents the state of the checkbox, then update the field's value to "ON" or "OFF" for example, whenever the checkbox is clicked.
Or else, handle the click event on click side and do ajax call to server to updated something.