I need to use objChildControl.RenderControl or objControl.RenderChildren to manually render my child controls. But it looks like these methods are incomplete.
All my child controls use the OnPreRender event to register clientscript and client stylesheets (since these can only be created in the prerender event).
I have 2 main issues, passing the current System.Web.UI.Page object to a child control and making sure the OnPreRender event is fired on these child controls.
It seems that I can't use the RenderControl method on my child controls since the OnPreRender event will not be called. I can however pass the Page object by objChildControl.Page = Me.Page
When I use RenderChildren I cannot pass the Page object, or can I? And i'm not sure if the OnPreRender event is even called when I use RenderChildren.
Some help would be appreciated, since i'm stuck ;)
Update
I found a way to get the result I need, but it is not the solution I want. Example:
Code I want:
<wc:ParentControl id="objParent" runat="server" bla="etc">
<Content> <!-- This is an InnerProperty of the ParentControl --><DIV>bla bla bla bla.....<wc:SomeControl id="objSomeControl" runat="server" /><wc:3rdPartyControl id="obj3rdPartyControl" runat="server" /></DIV></Content>
</wc:ParentControl>
CodeBehind: objParentControl.Content.RenderControl(Writer)
And then the issues mentioned above will begin. How to make sure that for all the children within Content the OnPreRender will be called?
Code which does work (but then the RenderControl method is just useless):
<wc:ParentControl id="objParentControl" runat="server"></wc:ParentControl>
<wc:Content id="objContent" runat="server"><DIV>bla bla bla bla.....<wc:SomeControl id="objSomeControl" runat="server" /><wc:3rdPartyControl id="obj3rdPartyControl" runat="server" /></DIV></wc:Content>
Then just use the RenderBeginTag and RenderEndTag of the wc:Content control. Then the OnPreRender event is called. But I wan't to embed the content into the parentcontrol by using an InnerProperty. And then manually rendering the childcontrols by RenderControl or RenderChildren.