
HasControls | 265
Page Class
This is the Title of the Book, eMatter Edition
Copyright © 2008 O’Reilly & Associates, Inc. All rights reserved.
Notes
If you want to perform data binding on a specific control on the page, such as a
DataGrid or DataList control, it may be more efficient to call DataBind on that
control rather than on the page, since calling it on the control will avoid any over-
head in calling DataBind on controls for which data binding is not needed.
FindControl
Control = Page.FinderControl(String)
Returns a reference to the control object whose name corresponds to a search
string. The FindControl method is a member of the base
Control class.
Parameters
Control
An instance of the
Control class that represents the control that is found
using the FindControl method. This control must be cast to the correct
control type to access members that are specific to the control type.
String
A string containing the programmatic identifier of the control. This value is
the same as the
ID attribute of a declarative control or, in the case of controls
created at runtime, is the same as the object name defined for the control.
Example
The example finds a control using its ID and changes its background color:
Sub Page_Load( )
Dim TheControl As Control = FindControl("Message")
If Not TheControl Is Nothing Then
Dim TheLabel As Label = CType(TheControl, Label)
TheLabel.Text = "Found the label named Message!" ...