How do you get the HTML for a web control?

  • Thread starter Thread starter Chad
  • Start date Start date
C

Chad

Your gonna ask why would I want to...

One reason is that the unsupported MS Web Tree Control has a text property
on a node, but no Controls collection. To add a control to the node, I need
its HTML, or I need to build it myslef (i'd rather not)

Any ideas?
 
Sorry to be slow, but how would I get the html for a TextBox control, for example.

I see a PreRender event..

Private Sub TextBox1_PreRender(ByVal sender As Object, ByVal e As System.EventArgs) Handles TextBox1.PreRender

End Sub

...and RenderBeginTag, RenderEndTag and RenderControl methods on the TextBox. None of them seem to apply.

Can you give me more info, please?
 
Hello Chad,

StringBuilder sb = new StringBuilder();
using (StringWriter sw = new StringWriter(sb))
using (Html32TextWriter writer = new Html32TextWriter(sw))
{
myTextBoxControl.RenderControl(writer);
}

// at this point, sb.ToString() has the html contents of the rendered control.
 
Back
Top