HtmlTextWriter Formatting Issues
-
Need help on the format of the produced output of the HtmlWriter class. I need to make properly indent the tags in the final rendered output. Sample:
string[] Names = new string[]
{
"Johnny",
"Mindy",
"Jossy",
"Kreuger",
"Marco"
};HtmlTextWriter writer = new HtmlTextWriter(new StringWriter()); writer.RenderBeginTag(HtmlTextWriterTag.Ul); foreach (string name in Names) { writer.RenderBeginTag(HtmlTextWriterTag.Li); writer.Write(name); writer.RenderEndTag(); writer.WriteLine(); } writer.RenderEndTag();
The produced output is this:
<ul>
<li>Johnny</li>
<li>Mindy</li>
<li>Jossy</li>
<li>Kreuger</li>
<li>Marco</li>
</ul>The closing ul tag is not indented properly. Any work around for this, thanks a lot.
-
Need help on the format of the produced output of the HtmlWriter class. I need to make properly indent the tags in the final rendered output. Sample:
string[] Names = new string[]
{
"Johnny",
"Mindy",
"Jossy",
"Kreuger",
"Marco"
};HtmlTextWriter writer = new HtmlTextWriter(new StringWriter()); writer.RenderBeginTag(HtmlTextWriterTag.Ul); foreach (string name in Names) { writer.RenderBeginTag(HtmlTextWriterTag.Li); writer.Write(name); writer.RenderEndTag(); writer.WriteLine(); } writer.RenderEndTag();
The produced output is this:
<ul>
<li>Johnny</li>
<li>Mindy</li>
<li>Jossy</li>
<li>Kreuger</li>
<li>Marco</li>
</ul>The closing ul tag is not indented properly. Any work around for this, thanks a lot.
This looks like some whitespace is rendered before the code snippet you've provided. If this is from the Render method of a control, it may be whitespace introduced in the designer.