Hey all.
I'm looking to create a WebControl that can house markup inside it, and do its own dynamic creation of child controls. The issue I'm having is that I can't (yet) render the controls housed in the markup (see example below) separate from the child controls I create.
I'm aware I need to set up the class with these 2 flags:
[ParseChildren(false)]
[PersistChildren(true)]
public class OuterControl : WebControl
{
...
}
And sample markup would look like:
<custom:OuterControl>
<asp:TextBox ...>
<custom:OuterControl>
Inside RenderContents(), I have some controls I need to add to the control tree, render, then render the ones wrapped in markup in a particular part. E.g.:
protected override void RenderContents(HtmlTextWriter output)
{
EnsureChildControls();
[ Misc work, render my controls ]
[** Would like to render wrapped children here **]
[ Possibly other misc work ]
}
As stated, I can either get my code-created controls to render twice from calling RenderChildren(), or the wrapped controls to not render at all by removing that line. Darn.
Thoughts?