Page.FindControl(String) Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Searches the page naming container for a server control with the specified identifier.
public:
override System::Web::UI::Control ^ FindControl(System::String ^ id);
public override System.Web.UI.Control FindControl(string id);
override this.FindControl : string -> System.Web.UI.Control
Public Overrides Function FindControl (id As String) As Control
Parameters
- id
- String
The identifier for the control to be found.
Returns
The specified control, or null if the specified control does not exist.
Examples
The following code example demonstrates how to use the FindControl method to locate controls inside templates. In this example, two Repeater controls are defined; each shows a different way to catch the Click event of a LinkButton inside the repeater item template.
<%@ Page Language="C#" %>
Page FindControl Example
<%@ Page Language="VB" %>
Page FindControl Example
Remarks
The FindControl method can be used to access a control whose ID is not available at design time. The method searches only the page's immediate, or top-level, container; it does not recursively search for controls in naming containers contained on the page. To access controls in a subordinate naming container, call the FindControl method of that container.