title: ASP.NET - Set CheckBoxList input tag "class" attribute
body: <p>I'm working with an asp.net 4.0 application and I am wondering if its possible to set the class attribute on the checkbox (the input tag) created by a checkbox list control. </p>
  
  <p>What the following does is wrap the input tag in a span tag and apply the class to that:</p>
  
  <pre><code>foreach (ListItem li in CheckBoxList1.Items)
  {
     li.Attributes.Add("class", "check-if-dirty");
  }
  </code></pre>
  
  <p>Creates:</p>
  
  <pre><code>&lt;span class="check-if-dirty"&gt;&lt;input id="MainContent_CheckBoxList1_0" type="checkbox" name="ctl00$MainContent$CheckBoxList1$0" value="a" /&gt;&lt;label for="MainContent_CheckBoxList1_0"&gt;a&lt;/label&gt;&lt;/span&gt;
  </code></pre>
  
  <p>What I want is this:</p>
  
  <pre><code>&lt;span&gt;&lt;input class="check-if-dirty" id="MainContent_CheckBoxList1_0" type="checkbox" name="ctl00$MainContent$CheckBoxList1$0" value="a" /&gt;&lt;label for="MainContent_CheckBoxList1_0"&gt;a&lt;/label&gt;&lt;/span&gt;
  </code></pre>
  
  <p>Thank you.</p>