Ok, I see. So I think first we should implement a method that list all ContentPlaceHolder control such as GetAllContentPlaceHolders. Then we will loop all get controls and search all inside controls. The GetAllContentPlaceHolders could be implemented as following code:
private IEnumerable<Control> GetAllContentPlaceHolders()
{
Queue<Control> controls = new Queue<Control>();
foreach (Control c in Page.Controls)
{
controls.Enqueue(c);
}
while (controls.Count > 0)
{
Control c = controls.Dequeue();
if (c is ContentPlaceHolder)
{
yield return c;
}
foreach (Control ic in c.Controls)
{
controls.Enqueue(ic);
}
}
}
After that in your orginal ListControlCollections method, you should replace AddControls(Page.Controls, controlList);
by
foreach (Control c in GetAllContentPlaceHolders())
{
AddControls(c.Controls, controlList);
}
Hope it helps Best regards, HauLD
Make it better.