title: add class to html label at runtime asp net
body: <p>I work on asp.NET, coding on server side with C#.</p>
  
  <p>In the "view" part, I only have a label in my body, which is server side :</p>
  
  <p><strong>HTML</strong></p>
  
  <pre><code>&lt;label runat="server" id="html_label_1"&gt;&lt;/label&gt;
  </code></pre>
  
  <p>I would like to change its class at runtime. Here is my 2 CSS classes :</p>
  
  <p><strong>CSS</strong></p>
  
  <pre><code>.label_error {
      color : red;
  }
  
  .label_success {
      color : green;
  }
  </code></pre>
  
  <p>I created 2 functions in C# (server side), which change the text of this label and should add the proper class like following :</p>
  
  <p><strong>C#</strong></p>
  
  <pre><code>protected void displayError(object error) 
  {
      string err = error.ToString();
  
      html_label_1.InnerText = err;
      /* this is where I want to toggle class to ".label_error" */
  }
  
  protected void displaySuccess(object success) 
  {
      string succ = success.ToString();
  
      html_label_1.InnerText = succ;
      /* this is where I want to toggle class to ".label_success" */
  }
  </code></pre>
  
  <p><strong>My Problem :</strong></p>
  
  <p>I didn't see any properties to set my own class. When [CTRL]+[SPACE] on server side on <code>html_label_1</code>, I only see <code>html_label_1.Style.Add()</code>, but this methods needs a string with the style, which is not my purpose.</p>
  
  <p>Can anyone lead me to a solution please ?</p>