You may want to skip this tip if you do not care about optimization in your server controls. Yeah right. When you are parsing out all the data that will go into your string, you may be tempted to distrust the HtmlTextWriter. 'Beware the groooooovvveeee.'
(sorry, sideline from one of my favorite kids movies, The Emperor's New Groove. Speaking of kids movies, have you seen the Incredibles? How awesome is that movie? I love it.) The HtmlTextWriter is
sequential meaning if you write a table tag, pass the writer off to another function, and then come back to write your closing table tag, all will be well. You do not and should not return a string from a different function and then render than through the writer. The only acceptable exception to this is using the StringBuilder if you
must. When you take a string called a and a string called b, and join those strings together, you know have three strings. The StringBuilder circumvents this nasty little overhead.
Another discreet and not so widely exploited values of the HtmlTextWriter are the Public and Protected methods of the devil in question. I will not take the time to list them here, as they are numerous, but their value is unquestionable. And, this leads us to ANOTHER value, if you use the Html enum values with the HtmlTextWriter, you get automatic down-level render support. In laymans terms, if you have a tag that older browsers do not support, you can specify which tag
should be shown in this instance.