I'm trying to grab the panels from a child page in ASP.NET, but when I use page.Controls, it only retrieves the elements from the master page.
I've tried using this, Page.Page, but always the same result, the elements of the master page and not the page in question. See the algorithm I used
public static void mostrarPanels(List<String> panels, Page page)
{
ControlCollection controls = page.Controls;
foreach(Control control in controls)
{
ControlCollection controls2 = control.Controls;
if (control.GetType() == typeof(Panel)) {
control.Visible = false;
for (int i = 0; i < panels.Count; i++)
{
if (control.ID == panels[i])
control.Visible = true;
}
}
}
}
Am I doing something wrong?