tags:

views:

91

answers:

3

If I start with

Page.Controls

Then recursively call all the children control.Controls, will the guarantee that I find all the controls that exist on a given page. Are there any time that orphaned controls can exist, or any other controls that will not show up when iterating through the page's controls in this way?

Even if this is correct is there a better way of finding all of a page's controls?

+2  A: 

It will find all the controls that exist when you ask. There's nothing to say that more controls won't be added later, after DataBinding, for instance.

Maybe you want to check in the OnPreRenderComplete method?

John Saunders
+2  A: 

Obviously, this will give you controls with runat=server specified. It won't give plain old HTML controls.

marcc
+1  A: 

I use ControlFinder helper for access to all my children controls. Get it and adapt to your code.

pho3nix