ASP.NET Parent 属性

定义和用法

Parent 属性获取对服务器控件的父控件的引用。

实例

本例显示包含 button 控件的 Parent 元素:

  1. <script runat="server">
  2. Sub Button1_Click(sender As Object, e As EventArgs)
  3. Response.Write("The Parent of the button control is: ")
  4. Response.Write(button1.Parent)
  5. End Sub
  6. </script>
  7. <form runat="server" >
  8. <asp:Button ID="button1" OnClick="Button1_Click"
  9. Text="Get Parent" runat="server" />
  10. </form>