Control.Parent Property
Gets a reference to the server control's parent control in the page control hierarchy.
Assembly: System.Web (in System.Web.dll)
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.
Private Sub Button1_Click(sender As Object, MyEventArgs As EventArgs) ' Find control on page. Dim myControl1 As Control = FindControl("TextBox2") If (Not myControl1 Is Nothing) ' Get control's parent. Dim myControl2 As Control = myControl1.Parent Response.Write("Parent of the text box is : " & myControl2.ID) Else Response.Write("Control not found.....") End If End Sub
Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.