I am migrating some old code where HtmlTextWriter is used extensively to render UI elements.
I am migrating the code to use ASP.NET MVC 1.0. As far as I am aware, I am not using any of the HtmlTextWriter specific function (such as indentation).
Currently, I am using a wrapper method to return string generated by the HtmlTextWriter as follow:
var sw = new StringWriter();
var xhtmlTextWriter = new XhtmlTextWriter(sw);
GenerateHtml(xhtmlTextWriter);
return sw.ToString();
My questions are:
I am trying to get
HtmlTextWriterinstance from ASP.NET MVC View, but apparently even the HtmlHelper does not use this. Do I miss anything?Each call to
GenerateHtmlwill generated small HTML pieces, generally not bigger than 1000 characters, but there can be a lot of calls. Is it worth rewriting theHtmlTextWriterdependent code into StringBuilder? Or instead, what about creating aHtmlTextWriterinstance which will be used on all calls (and flushed at the end of the iterations).