Page.FindControl Method (String)

Searches the page naming container for a server control with the specified identifier.

Namespace: System.Web.UI
Assembly: System.Web (in system.web.dll)

public:
virtual Control^ FindControl (
	String^ id
) override
public Control FindControl (
	String id
)
public override function FindControl (
	id : String
) : Control
Not applicable.

Parameters

id

The identifier for the control to be found.

Return Value

The specified control, or a null reference (Nothing in Visual Basic) if the specified control does not exist.

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.

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.

No code example is currently available or this language may not be supported.

Windows 98, Windows Server 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0, 1.1, 1.0

Community Additions

ADD
Show: