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
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 :)
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;
}