title: How to add attributes correctly upon rendering with a HtmlTextWriter?
body: <p>I want to add the href attribute to a link element. This is my code:</p>
  
  <pre><code>System.Text.StringBuilder stringBuilder = new System.Text.StringBuilder();
  using (System.IO.StringWriter stringWriter = new System.IO.StringWriter(stringBuilder))
  {
   using (System.Web.UI.HtmlTextWriter htmlTextWriter = new System.Web.UI.HtmlTextWriter(stringWriter))
   {
  
    htmlTextWriter.RenderBeginTag(HtmlTextWriterTag.Ul);
    htmlTextWriter.RenderBeginTag(HtmlTextWriterTag.Li);
    htmlTextWriter.RenderBeginTag(HtmlTextWriterTag.A);
    htmlTextWriter.AddAttribute(HtmlTextWriterAttribute.Href, "http://www.google.de");
    htmlTextWriter.Write("Google");
    htmlTextWriter.RenderEndTag();
    htmlTextWriter.RenderEndTag();
  
  
    htmlTextWriter.RenderEndTag();
   }
  }
  </code></pre>
  
  <p>It renders as:</p>
  
  <pre><code>&lt;ul&gt;
   &lt;li&gt;&lt;a&gt;Google&lt;/a&gt;&lt;/li&gt;
  &lt;/ul&gt;
  </code></pre>
  
  <p>This is what I expected.</p>
  
  <pre><code>&lt;ul&gt;
   &lt;li&gt;&lt;a href="http://www.google.de"&gt;Google&lt;/a&gt;&lt;/li&gt;
  &lt;/ul&gt;
  </code></pre>
  
  <p>What went wrong and how can I fix this issue?</p>
  
  <p>Please don't answer that I could assemble the string in some other way. I want to know how I can achieve this with the HtmlTextWriter</p>