title: How to change HTML class attribute on a tag on page load ASP .NET C#
body: <p>I need to know how to change the css class on a tag on page load.. in PHP this was much easier all i had to do is to write <code>&lt;tagNAme class="&lt;?php echo "className"; ?&gt;"&gt;</code> ...</p>
  
  <p>I was able to write php code blockes with in tags.. but in ASP .NET this doesn't seem to work</p>
  
  <p>I tried  <code>&lt;% tagElementId.attribute.add("class","cssName"); %&gt;</code>  after the tag i wanted to change the css in ASPX file....but didn't work..</p>
  
  <p>My scanario is i need to check password textbox and on login button click..if the password is wrong password textbox should have a class called "error" otherwise a css class named "userinput"</p>
  
  <p>How do I do it?</p>
  
  <p>EDIT</p>
  
  <pre><code>&lt;form id="loginPanel" runat="server"&gt;
          &lt;ul&gt;
              &lt;li&gt;
                  &lt;h3&gt;
                      Log on&lt;/h3&gt;
              &lt;/li&gt;
              &lt;li&gt;
                  &lt;label for="userId"&gt;
                      User ID :&lt;/label&gt;
  
                  &lt;asp:TextBox ID="userId" name="userId" class="loginTextInput" runat="server"&gt;&lt;/asp:TextBox&gt;
  
              &lt;/li&gt;
              &lt;li&gt;
                  &lt;label for="password"&gt;
                      Password :&lt;/label&gt;
  
                  &lt;asp:TextBox ID="password" name="password" class="loginTextInput" 
                      runat="server" ontextchanged="password_TextChanged"&gt;&lt;/asp:TextBox&gt;
  
              &lt;/li&gt;
              &lt;li&gt;
                  &lt;asp:Button ID="logInButton" runat="server" Text="Log on" OnClick="logInButton_Click" /&gt;
                  &lt;li class="forgotUserText"&gt;Forgot &lt;a href="#" class="forgotUser"&gt;User ID &lt;/a&gt;or &lt;a
                      href="#" class="forgotUser"&gt;Password?&lt;/a&gt; &lt;/li&gt;
  
          &lt;/ul&gt;
          &lt;/form&gt;
  </code></pre>
  
  <p>`</p>