title: asp.net select all/none checkboxes
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/8730471/javascript-or-jquery-to-check-and-uncheck-all-checkbox">Javascript or Jquery to check and uncheck all checkbox</a>  </p>
  </blockquote>
  
  
  
  <p>I have 12 asp:checkboxes on a page and I would like to add one which selects/deselects all of them.
  What's the best way to do that?</p>
  
  <p>I've seen people use jquery but I'm not very familiar with JS.
  IS there a generic jquery finction to use?</p>
  
  <pre><code>&lt;head&gt;...
     &lt;script src="Scripts/jquery-1.7.1.min.js" type="text/javascript"&gt;&lt;/script&gt;
  ...&lt;/head&gt;
  
  &lt;body&gt;...
      &lt;script type="text/javascript"&gt;
          function Selectall() {
              if ($('.JchkAll').is(':checked')) {
                  // .JchkGrid cssClass will be assigned to all other checkboxes in your control 
                  $('.JchkGrid').attr('checked', 'true');
              }
              else {
                  $('.JchkGrid').removeAttr('checked', 'false');
              }
          } 
      &lt;/script&gt;
  &lt;form&gt;...
  &lt;asp:CheckBox runat="server" ID="cbSelectAll" Text="Select/Deselect All" CssClass="JchkAll" onchange="Selectall();"/&gt;
          &lt;asp:CheckBox runat="server" ID="cbName" Text="Name" class="JchkGrid"/&gt;
          &lt;asp:CheckBox runat="server" ID="cbModel" Text="Model" CssClass="JchkGrid"/&gt;
  ...&lt;/form&gt;
  ...&lt;/body&gt;
  </code></pre>