title: CSS Style not being set Dynamically in ASP.NET Code behind
body: <p>I'm trying to change the CSS class and attributes of a set of asp.net controls via the code behind using this:</p>
  
  <p>ASP.NET:</p>
  
  <pre><code>&lt;span id="followbtn_mainbtn" runat="server" class="follow-btner" onclick="profile_followers_follow(this)"&gt;
  
          &lt;img id="img_followingbtn" runat="server" class="profile-single-profile-follow-btn-img" src="icons/profico/following.png" style="display: none;"&gt;
          &lt;img id="img_unfollowbtn" runat="server" class="profile-single-profile-unfollow-btn-img" src="icons/profico/unfollow.png" style="display: none;"&gt;
          &lt;img id="img_followicon" runat="server" class="profile-single-profile-follow-icon" src="icons/profico/followIcon.png"&gt;
  
          &lt;span id="span_following_text" runat="server" class="profile-single-profile-follow-btn-following"&gt;Follow&lt;/span&gt;
          &lt;span id="span_unfollow_text" runat="server" class="profile-single-profile-follow-btn-unfollow" style="display: none;"&gt;Unfollow&lt;/span&gt;
  
        &lt;/span&gt;
  </code></pre>
  
  <p>Code:</p>
  
  <pre><code>followbtn_mainbtn.Attributes.CssStyle.Add("className", "follow-btner-no-hoverer");
  span_unfollow_text.InnerText = "Following";
  img_followingbtn.Attributes.CssStyle.Add("display", "block");
  img_unfollowbtn.Attributes.CssStyle.Add("display", "block");
  span_unfollow_text.Attributes.CssStyle.Add("display", "block");
  </code></pre>
  
  <p>However when I run this, I do not see the desired results. If I hard code the appropriate classes to the controls, they work properly but the code doesn't do it dynamically. </p>
  
  <p>What am I doing wrong?</p>