title: Assigning CSS to dynamically created Label in C#
body: <p>I'm trying to figure out how to apply CSS to a Label created in C#.  Everything compiles and runs, it just doesn't seem to be applying the CSS.  The CSS is in the file linked to in the site master page.  Everything else in the CSS file is being applied as it should be. </p>
  
  <p>Codebehind:</p>
  
  <pre><code>...
  Label label = new Label();
  SqlCommand command = new SqlCommand("SELECT Q_Text FROM HRA.dbo.Questions WHERE QID = 1");
  command.Connection = connection;
  reader = command.ExecuteReader();
  reader.Read();
  label.Text = reader["Q_Text"].ToString();
  label.ID = "rblabel";
  label.CssClass = "rblabel";
  reader.Close();
  holder.Controls.Add(label);
  ...
  </code></pre>
  
  <p>ASP:</p>
  
  <pre><code>&lt;asp:Content runat="server" ID="BodyContent" ContentPlaceHolderID="MainContent"&gt;
      &lt;asp:PlaceHolder ID="holder"  runat="server"&gt;
  
      &lt;/asp:PlaceHolder&gt;
  &lt;/asp:Content&gt;
  </code></pre>
  
  <p>CSS:</p>
  
  <pre><code>.rblabel {
      text-align:left;
      padding-left: 2em;
      font-size: 4em;
  }
  </code></pre>
  
  <p>EDIT: added the HTML as well as the <code>Control.Add()</code> statement in my code (forgot to include that in my copy/pase).  This HTML is the etirety of what is put into that <code>PlaceHolder</code>.</p>
  
  <p>HTML:</p>
  
  <pre><code>&lt;section class="content-wrapper main-content clear-fix"&gt;
      &lt;span id="MainContent_rblabel" class="rblabel"&gt;TEST TEST TEST&lt;/span&gt;
      &lt;table id="MainContent_ctl00" class="radio"&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;input id="MainContent_ctl00_0" type="radio" name="ctl00$MainContent$ctl00"value="1" /&gt;
          &lt;label for="MainContent_ctl00_0"&gt;Excellent&lt;/label&gt;&lt;/td&gt;
      &lt;/tr&gt;&lt;tr&gt;
    &lt;td&gt;&lt;input id="MainContent_ctl00_1" type="radio" name="ctl00$MainContent$ctl00" value="1" /&gt;
           &lt;label for="MainContent_ctl00_1"&gt;Good&lt;/label&gt;&lt;/td&gt;
      &lt;/tr&gt;&lt;tr&gt;
     &lt;td&gt;&lt;input id="MainContent_ctl00_2" type="radio" name="ctl00$MainContent$ctl00"value="1" /&gt;
            &lt;label for="MainContent_ctl00_2"&gt;Fair&lt;/label&gt;&lt;/td&gt;
      &lt;/tr&gt;&lt;tr&gt;
     &lt;td&gt;&lt;input id="MainContent_ctl00_3" type="radio" name="ctl00$MainContent$ctl00"value="1" /&gt;
           &lt;label for="MainContent_ctl00_3"&gt;Poor&lt;/label&gt;&lt;/td&gt;
      &lt;/tr&gt;
  &lt;/table&gt;
  &lt;/section&gt;
  </code></pre>