I am trying to render a composite control to a string and write it to the page as such:
Dim sb As New StringBuilder
Dim sw As New StringWriter(sb)
Dim hw As New HtmlTextWriter(sw)
Dim CustomCompositeControl as New MyCustomCompositeControl
CustomCompositeControl.RenderControl(hw)
HttpContext.Current.Response.Write(sb.ToString)
Unfortunately it is merely rendering a empty span tag.
Is it even possible to render CompositeControls into strings as you would, say, a DataGrid?
Without getting into the literal internals of my CompositeControl, is there something I should be making sure of inside the CompositeControl before it can be rendered via RenderControl?
NOTE: I am not overriding the RenderControl in my CompositeControl. Do I need to do that?
UPDATE Ok. I sorta figured this out. I have to make sure my CompositeControl's EnsureChildControls method is called before the RenderControl method runs. I'm just not so sure about the best spot to call it internally.