I have tried this two different ways.. not a great deal on this in the forum either.
I am trying to create a custom taghelper slowly building it up as I move forward. Its to produce a dynamic menu however I am not getting the right output from string builder.
I am trying to produce this for the precontent:
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav">
and this for the postcontent:
</ul>
</div>
I intended to add this as output.precontent and output.postcontent. I also decided to use a tagbuilder approach for each tag and to add them to a stringbuilder finally rendering it as the forementioned precontent. This is what I came up with.
StringBuilder PreContentSb = new StringBuilder();
StringBuilder PostContentSb = new StringBuilder();
TagBuilder divTag = new TagBuilder("div");
TagBuilder ul = new TagBuilder("ul");
divTag.MergeAttribute("class", "navbar - collapse collapse");
divTag.TagRenderMode = TagRenderMode.SelfClosing;
ul.MergeAttribute("class", "nav navbar - nav");
ul.TagRenderMode = TagRenderMode.SelfClosing;
PreContentSb.Append(' ', 12);
PreContentSb.Append(divTag.InnerHtml.ToString());
PreContentSb.Append(Environment.NewLine);
PreContentSb.Append(' ', 16);
PreContentSb.Append(ul.ToString());
PreContentSb.Append(Environment.NewLine);
output.PreContent.SetContent(PreContentSb.ToString());
PostContentSb.Append(' ', 16);
PostContentSb.Append("</ul>");
PreContentSb.Append(Environment.NewLine);
PostContentSb.Append(' ', 12);
PostContentSb.AppendLine("</div>");
PreContentSb.Append(Environment.NewLine);
output.PostContent.SetContent(PostContentSb.ToString());
The taghelper is only going in one place so I thought I would indent for that place to start with eg "PreContentSb.Append(' ', 12);"..
The problem I am getting is that when I look at page source I am getting, for these tags the following:
Microsoft.Extensions.Internal.BufferedHtmlContent
 Microsoft.AspNet.Mvc.Rendering.TagBuilder
 </ul> </div>

First of all its not rendering the tagbuilt tags at all and secondly instead of inverted commas and angle brackets its displaying the actual Character entity references..
How do I simply display the inverted commas, angle brackets?
Finally how do you render a tagbuilder element in a stringbuilder?