Struggling to move away from recursive Page.FindControl
<p>I have developed a web dashboard which has a structure of controls embedded inside of controls. In many scenarios I have the ID of a control and need to be working on the actual control object. As such, I use a utility method, a recursive FindControl implementation, which searches Page (or any other provided object, but I always use Page), for the ID of the control.</p>

<pre><code>/// &lt;summary&gt;
/// Page.FindControl is not recursive by default.
/// &lt;/summary&gt;
/// &lt;param name="root"&gt; Page &lt;/param&gt;
/// &lt;param name="id"&gt; ID of control looking for. &lt;/param&gt;
/// &lt;returns&gt; The control if found, else null. &lt;/returns&gt;
public static Control FindControlRecursive(Control root, string id)
{
    if (int.Equals(root.ID, id))
    {
        return root;
    }

    foreach (Control control in root.Controls)
    {
        Control foundControl = FindControlRecursive(control, id);

        if (!object.Equals(foundControl,null))
        {
            return foundControl;
        }
    }

    return null;
}
</code></pre>

<p>This function has the ability to become quite slow. I realize just how slow once I put log4net logging into it. I am now trying to move away from it where I can, but I am not sure what other options I have, if any.</p>

<p>For instance, the user drag-and-drops a control onto my web page. The event handler looks like this:</p>

<pre><code>protected void RadListBox_Dropped(object sender, RadListBoxDroppedEventArgs e)
{
    //e.HtmlElementID is the UniqueID of the control I want to work upon.
    RadDockZone activeControlDockZone = Utilities.FindControlRecursive(Page, e.HtmlElementID) as RadDockZone;
}
</code></pre>

<p>There is no guarantee that this control will be the direct child of Page, and I do not (as far as I know!), have the ability to determine where in my controls this ID could be except by searching from Page downward. </p>

<p>The only thing I can think up is keeping a lookup table of every object on Page, but that seems like the wrong idea.</p>

<p>Has anyone else experienced this issue?</p>
