Parent Property

Control.Parent Property


Gets a reference to the server control's parent control in the page control hierarchy.

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

public virtual Control Parent { get; }

Property Value

Type: System.Web.UI.Control

A reference to the server control's parent control.

Whenever a page is requested, a hierarchy of server controls on that page is built. This property allows you to determine the parent control of the current server control in that hierarchy, and to program against it.

Legacy Code Example

The following example sets a new Control object on a page, myControl1, to the control specified in a FindControl method call. If the call returns a control, the code uses the Parent property to identify the control that contains myControl1. If the parent control exists, the string "The parent of the text box is" is concatenated with the ID property of the parent control and written to the Page. If no parent control is found, the string "Control not found" is written.

Code snippet is not found. Confirm that the code snippet name 'System.Web.UI.Page.Parent_FindControl' is correct.

.NET Framework
Available since 1.1
Return to top
© 2015 Microsoft