While working on Ajax Data Controls Project, I need the generated HTML from an ITemplate. Here is the code that generates the html, some of you may find it useful.
1: StringBuilder output = new StringBuilder();
2: StringWriter sw = new StringWriter(output, CultureInfo.InvariantCulture);
3: HtmlTextWriter htw = new HtmlTextWriter(sw);
4:
5: Control control = new Control(); // Create a Fake control to act as a Container
6:
7: template.InstantiateIn(control); // This is the ITemplate
8: control.RenderControl(htw);//Dump the control in HTMLWriter
9:
10: htw.Close();
11:
12: string html = output.ToString(); // This is the generated HTML