Overview
The code below demonstrate how to use JavaScript to get all the checkbox elements of a particular checkbox list, and then check / unchecked them base on the status of another checkbox (the sender).
This technique is also useful when you want to do other operation (e.g. ensure single selection) to all checkboxes of a checkbox list.
Reference
Check/Uncheck all items in a CheckBoxList using ASP.NET and Javascript
Code Snippet
This code is directly copied from Check/Uncheck all items in a CheckBoxList using ASP.NET and Javascript
function CheckBoxListSelect(cbControl, state)
{
var chkBoxList = document.getElementById(cbControl);
var chkBoxCount= chkBoxList.getElementsByTagName("input");
for(var i=0;i<chkBoxCount.length;i++)
{
chkBoxCount[i].checked = state;
}
return false;
}