Some people may have already read Steve Orr's Article on control tree
recursion, and may be wondering what differences there may be when using the
.NET Framework 2.0. When using the .NET Framework 2.0, one may throw all kinds
of monkey wrenches into the situation.
One of these would be using a "Master Page". When
using a "Master Page", you will only see one control, which will be
the master page that your current page is inheriting. This creates a problem,
when trying to access a control that lies within the page itself. When creating
a page without utilizing a master page, you will also find it difficult to find
your controls, if you loop through the "Page.Controls" collection. This
particular issue has an easy fix. The fix is to reference the Form within the
page and loop through its controls.
Listing 1
Control oFrm = Page.Form;
//loop through panel controls
foreach (Control oCtl in oFrm.Controls)
{
//find your control and do with it as you like here
.....
}