Find control in usercontrol from usercontrol

Vote:
 
I'm creating a new ascx usercontrol placed in the DefaultFramework masterpage. How do I access the PageTreeControl located in Menu.ascx from the codebehinde. Best Regards /Tomas
#12315
Mar 25, 2008 18:34
Vote:
 
Hi Thomas! You can either create a Property in your usercontrol which sets the PageTreeData for your control. The Page or the Frameset can set this as it already knows about the data for the Menu. or you can use the Page.FindControl(idOfControlToFind) method for the page to find the Menu control (you have access to the Page object in your ascx codebehind). This is somewhat slower as the Page must search in it's controlhierarchy. Cast the found control to a Menu object and you can use it's FindControl() method to find the PageTreeControl. I would go for the first solution :)
#14045
Mar 25, 2008 18:44
Vote:
 
I have the same problem. Can you give any code examples? I want to set the datasource for my second level menu pagetree to be my topmenu menulist.
#14046
Mar 25, 2008 18:44
Vote:
 
There is an example of how this can be done in the sample templates. The framework is responsible to set a property for the MenuList control that is used by the level 2 PageTree. private void Page_Init(object sender, System.EventArgs e) { if(TopMenu != null && LeftMenu != null) LeftMenu.MenuListControl = TopMenu.MenuListControl; }
#14047
Mar 25, 2008 18:44