Using the Controls Collection in an ASP.NET Web Page
The Control class and its derived classes (including the Page class) expose a Controls property that returns a ControlCollection instance. This hierarchy allows you to walk the control tree programmatically to search for specific controls on a page, as well as to check the type of controls within the collection in order to access their properties. The following code example shows how to walk through the page's control hierarchy to find instances of the <asp:TextBox> control (of which there is only one).
Security Note: |
|---|
This example has a text box that accepts user input, which is a potential security threat. By default, ASP.NET Web pages validate that user input does not include script or HTML elements. For more information, see Script Exploits Overview. |
Security Note: