Looping through asp:CheckBox controls
<p>I have 11 of these controls on my page, all are checkboxes.  It is contained within a master page.</p>

<p>I can accomplish what I want like so:</p>

<pre><code>generalInformation.InputAttributes.Add( "class", "SetupChecklist" );
generalInformation2.InputAttributes.Add( "class", "SetupChecklist" );
generalInformation3.InputAttributes.Add( "class", "SetupChecklist" );
</code></pre>

<p>Etc..</p>

<p>I am now trying to loop through these and do the same thing to save myself some code, but I am having a lot of trouble getting this to work properly, well I can't get it to work at all.</p>

<p>Can anyone give me a good way to loop through these 11 checkbox controls and add the css class SetupChecklist?</p>

<p>I tried this and it isn't adding the class for some reason.</p>

<pre><code>protected void InitializeCheckboxes ()
    {
        //generalInformation.InputAttributes.Add( "class", "SetupChecklist" );
        var allCheckBoxes = Page.Controls.OfType&lt;CheckBox&gt;();
        foreach ( var c in allCheckBoxes )
        {
            c.InputAttributes.Add( "class", "SetupChecklist" );
        } 
    }
</code></pre>

<p>I go call <code>InitializeCheckboxes();</code> in the Page_Load method.  It does work when I just use generalInformation.InputAttribues.Add etc..  But not when I loop through them.  Any suggestions?</p>
