Click here to Skip to main content
15,896,344 members

C#
StringBuilder sb = new StringBuilder();
sb.append("<html>");
sb.append("<head></head>");
sb.append("<body>");
sb.append("<div>My Test Div </div>");
sb.append("</body>");
sb.append("</html>");
 
Share this answer
 
or you can use Tag Builder. TagBuilder is a class that specially designed for creating html tags and their content.

C#
var tb = new TagBuilder("a");
tb.MergeAttribute("href",link);
tb.AddCssClass(cssClass);
tb.ToString(TagRenderMode.SelfClosing);
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900