I am creating some html from code running on a WinForm. I want to create the following html:
<html>
<body>
<div>
<p>foo</p>
</div>
</body>
</html>
I'm using the System.Web.UI.HtmlTextWriter class to do this like so:
System.Web.UI.HtmlTextWriter htmlWriter = new System.Web.UI.HtmlTextWriter();
htmlWriter.WriteFullBeginTag("html");
htmlWriter.WriteLine();
htmlWriter.WriteFullBeginTag("body");
htmlWriter.WriteLine();
htmlWriter.Indent++;
htmlWriter.WriteFullBeginTag("div");
htmlWriter.WriteLine();
htmlWriter.Indent++;
htmlWriter.WriteFullBeginTag("p");
htmlWriter.Write("foo");
htmlWriter.WriteEndTag("p");
htmlWriter.Indent--;
htmlWriter.WriteLine();
htmlWriter.WriteEndTag("div");
htmlWriter.Indent--;
htmlWriter.WriteLine();
htmlWriter.WriteEndTag("body");
htmlWriter.WriteLine();
htmlWriter.WriteEndTag("html");
This works just fine, however, when I open the resulting html in a text editor my indentation just looks way too far to me, since it is using tab chars. Is there a way to force this class to use a number of spaces instead?