title: asp.net c# 4 checkbox validation
body: <p>I'm just sitting in front of my first real asp.net c# project and I dont know how to validate that the user must checked 4 checkboxes to get to the next step on my site.</p>
  
  <p>ASP.Net</p>
  
  <pre><code>&lt;div class="panel-body"&gt;
  &lt;p&gt;Select 4 Items from the List&lt;/p&gt;
   &lt;label class="checkbox"&gt;
      &lt;asp:CustomValidator ID="SelectValidator" runat="server"
          ErrorMessage="Please select FOUR (4) Items!"
          OnServerValidate="SelectValidator_ServerValidate"&gt;&lt;/asp:CustomValidator&gt;
      &lt;asp:CheckBox ID="CheckBox1" Text="" runat="server" /&gt;&lt;br&gt;
      &lt;asp:CheckBox ID="CheckBox2" Text="" runat="server" /&gt;&lt;br&gt;
      &lt;asp:CheckBox ID="CheckBox3" Text="" runat="server" /&gt;&lt;br&gt;
      &lt;asp:CheckBox ID="CheckBox4" Text="" runat="server" /&gt;&lt;br&gt;
      &lt;asp:CheckBox ID="CheckBox5" Text=" " runat="server" /&gt;&lt;br&gt;
      &lt;asp:CheckBox ID="CheckBox6" Text="" runat="server" /&gt;&lt;br&gt;
      &lt;asp:CheckBox ID="CheckBox7" Text="" runat="server" /&gt;&lt;br&gt;
      &lt;asp:CheckBox ID="CheckBox8" Text="" runat="server" /&gt;&lt;br&gt;
      &lt;asp:CheckBox ID="CheckBox9" Text="" runat="server" /&gt;&lt;br&gt;
  &lt;/label&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>Code Behind</p>
  
  <pre><code> protected void SelectValidator_ServerValidate(object source, ServerValidateEventArgs args)
   {
       args.IsValid = CheckBox1.Checked;
   }
  </code></pre>
  
  <p>That is what I have and found in the internet right now for Server and Clientsite.</p>