asp.net.ph

Control.FindControl Method ( String )

System.Web.UI Namespace   Control Class


Searches the current naming container for a control with the specified id.

[ VB ]
Overloads Overridable Public Function FindControl ( _
   ByVal id As String _
) As Control

[ C# ]
public virtual Control FindControl (
   string id
);

[ C++ ]
public: virtual Control* FindControl (
   String* id
);

[ JScript ]
public function FindControl (
   id : String
) : Control;

Parameters

id
The identifier for the control to find.

Return Value

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

Example

The following example demonstrates using the FindControl method.

NOTE: This example shows how to use one of the overloaded versions of FindControl. For other examples that might be available, see the individual overload topics.

private void Button1_Click ( object sender, EventArgs MyEventArgs ) {
   // Find control on page.
   Control myControl1 = FindControl ( "TextBox2" );
   if ( myControl1 != null ) {
      // Get control's parent.
      Control myControl2 = myControl1.Parent;
      Response.Write ( "Parent of the text box is : " + myControl2.ID );
   } else {
      Response.Write ( "Control not found" );
   }
}
  C# VB

See Also

Control Members   Control.FindControl Overload List Skip Navigation Links




Home
Suggested Reading


Previous page Back to top Next page

© 2000-2010 Rey Nuñez All rights reserved.

If you have any question, comment or suggestion
about this site, please send us a note

You can help support asp.net.ph