Page Member

  • Thread starter Thread starter rn5a
  • Start date Start date
R

rn5a

I have a user control page named MyUC.ascx which has a Panel control
This Panel, in turn, has a TextBox. Next I use this user control in an
ASPX page named MyPage.aspx by registering the user control using the
following Register directive in the ASPX page

<%@ Register TagPefix="UC" TagName="UControl" Src="MyUC.ascx" %>

<form runat="server">
<UC:UControl ID="uc1" runat="server"/>
</form>

Now if I am not mistaken, the hierarchy of the controls in the ASPX
page would be

Page
Form
User Control
Panel
TextBox

As per the above hierarchy diagram, the TextBox is a member of the
Panel's Controls Collection but isn't the TextBox also a member of the
Page's Controls Collection here?
 
nope :)

The Controls collection only contains the children controls, not the
children of the children (and so on).
 
Velislav, that means that even the Panel control is not a member of the
Page's Control Collection but the user control is a member of the
Page's Controls Collection, isn't it? Please correct me if I am wrong.

Thanks for the prompt response.
 
As per the above hierarchy diagram, the TextBox is a member of the
Panel's Controls Collection but isn't the TextBox also a member of the
Page's Controls Collection here?

No.
 
That is correct, the Panel is part of the User Control's Controls, but
not the Page's Controls.

To get to the Panel from the Page, you'd have to do something like

Page.Controls[userControlIndex].Controls[panelControlIndex]
 
The defining element here is the concept of Controls that are part of the
Page's Control tree, but which controls have their own child control
hierarchy.
Peter
 
Back
Top