Q:

ASP.NET MVC 3.0 TagBuilder add Newline after tag

I am building such kind of ul using class TagBuilder
var ulTag = new TagBuilder("ul");
...
foreach(..items...)
{
  var liTag = new TagBuilder("li");
  ....
  ulTag.InnerHtml += liTag.ToString();
}

return new MvcHtmlString(ulTag.ToString());

But the output html getting produced in one line like that
<ul id="menu"><li><a href="/">Home</a></li><li><a href="/About">About</a></li>.....</ul>

But i want to have it like that:
<ul id="menu">
    <li><a href="/">Home</a></li>
    <li><a href="/About">About</a></li>
    .....
</ul>

Is there any way to add \r\t or kind of Environment.NewLine after each tag?

A:

Not really a clean way but it might work:
var ulTag = new TagBuilder("ul");
ulTag.InnerHTML += Environment.NewLine;
foreach(..items...)
{
    var liTag = new TagBuilder("li");
    ulTag.InnerHTML += string.Format("  {0}{1}", liTag.ToString(), Environment.NewLine);
    ...
}

