ASP.NET RenderControl or RenderChildren Error

I need to use objChildControl.RenderControl or objControl.RenderChildren to manually display my child controls. But these methods seem to be incomplete.

All of my child controls use the OnPreRender event to register client and client tables (since they can only be created in the prerender event).

I have 2 main questions that pass the current System.Web.UI.Page object to a child control and certifies that the OnPreRender event is fired on these child controls.

It seems that I cannot use the RenderControl method for my child controls, since the OnPreRender event will not be raised. However, I can pass the object Page objChildControl.Page = Me.Page

When I use RenderChildren, I can not pass the Page object, or can I? And I'm not sure if the OnPreRender event is even raised when I use RenderChildren.

Some help would be appreciated since I was stuck;)

Update

I found a way to get the result I need, but this 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 questions mentioned above will begin. How to make sure that OnPreRender will be called for all Content child elements?

Code that works (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>

RenderBeginTag RenderEndTag wc: Content. OnPreRender. parentcontrol InnerProperty. childcontrols RenderControl RenderChildren.

+3
1

. , , , , , , ParseChildren(true) . ParseChildren , , , OnPreRender.

CreateChildControls , Controls. Render, , Controls , , .

- :

[ParseChildren(true, "MyKids")]
public class Example : Control {

    private ArrayList _kids = new ArrayList();

    public ArrayList MyKids {
        get { return _kids; }
        set { _kids = value; }
    }

    protected override CreateChildControls() {
        Controls.Clear();
        foreach(Control c in _kids)
            Controls.Add(c);
    }

    protected override Render(HtmlTextWriter writer) {
        ...
    }
}
+2

Source: https://habr.com/ru/post/1723448/