title: ASP.Net attributes["class"] = "";
body: <p>I have a contact form in my web site. When I control the <code>mailTo</code> like this:</p>
  
  <pre><code>if (!reg.IsMatch(mailTo.Value))
  </code></pre>
  
  <p>I will add attributes: <code>name = class</code>, <code>value = error</code>. 
  It runs correctly but when I tried to set <code>mailTo.Attributes["class"] = "";</code> it doesnt work correctly.</p>
  
  <p>Codebehind code:</p>
  
  <pre><code>Regex reg = new Regex(@"^([0-9a-zA-Z]([-.\w]*[0-9a-zA-Z])*@([0-9a-zA-Z][-\w]*[0-9a-zA-Z]\.)+[a-zA-Z]{2,9})$");
  //Kontroller
  if (!reg.IsMatch(mailTo.Value))
        mailTo.Attributes.Add("class", "error");
  else
        mailTo.Attributes["class"] = "";
  </code></pre>
  
  <p>Web page code:</p>
  
  <pre><code>&lt;asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Always"&gt;
      &lt;ContentTemplate&gt;
          &lt;span style="color: #777; text-shadow: 1px 1px 1px white;"&gt;İsim:&lt;/span&gt;
           &lt;input id="isim" runat="server" style="color: rgb(85, 85, 85);" type="text" name="name" /&gt;
          &lt;span style="color: #777; text-shadow: 1px 1px 1px white;"&gt;Email:&lt;/span&gt;
           &lt;input id="mailTo" runat="server" style="color: rgb(85, 85, 85);" type="text" name="email" /&gt;
          &lt;span style="color: #777; text-shadow: 1px 1px 1px white;"&gt;Mesaj:&lt;/span&gt;
           &lt;textarea id="mesaj" runat="server" style="color: rgb(85, 85, 85);" name="message"
                                              rows="3" cols="4"&gt;&lt;/textarea&gt;
            &lt;asp:Button ID="Button1" runat="server" CssClass="sendbutton sendmail" OnClick="Button1_Click"
                                              Text="Yolla" OnClientClick="easyNotification();" /&gt;
     &lt;/ContentTemplate&gt;
     &lt;Triggers&gt;
        &lt;asp:AsyncPostBackTrigger ControlID="Button1" EventName="Click" /&gt;
     &lt;/Triggers&gt;
  &lt;/asp:UpdatePanel&gt;
  </code></pre>