I'd like to intercept parsing of each control in the entire sub-tree of my own User Control.
Currently I've overridden the protected method Control.AddParsedSubObject in my user control. It's limited to interception of parsing on the immediate child controls in the declarative syntax because each of those controls has its own AddParsedSubObject method to further parse its own child controls.
From the User Control I can't get into the childrens' children to intercept those parsing calls.
In the following declarative example of my user control I can access the tv object from inside the User Control's AddParsedSubObject override.
<asp:TreeView runat="server" id="tv" />
However I cannot access the tv object in the following example (or the other children of the first Panel) because that parsing is handled by the Panel instead or its children.
<asp:Panel runat="server">
<asp:TreeView runat="server" id="tv" />
<asp:Panel runat="server">
<asp:TextBox runat="server" />
</asp:Panel>
</asp:Panel>
My code-behind in the user control looks like this
// User control interception of its parsed children
protected override void AddParsedSubObject(object obj) {
// Do some custom work with the control object.
if (obj is Control && ((Control)obj).ID == "tv") {
TreeView tv = (TreeView)obj;
DoSomethingWithParsedObject(tv);
}
// Let ASP.NET continue and put the control in the page hierarchy
base.AddParsedSubObject(obj);
}
Looking for ideas about how I can intercept parsing of each control in the entire sub-tree of my user control. For example, I want to write out custom information at each parse step.