This is a migrated thread and some comments may be shown as answers.

Issue with dynamically added menu

1 Answer 53 Views
Menu
This is a migrated thread and some comments may be shown as answers.
Madhu
Top achievements
Rank 1
Madhu asked on 15 Dec 2012, 02:09 PM
Hi,
  Here is the situation:
   I have a master page with telerik menu control (ID=testMenu)with  2 top level menu items "A", "B" . In the page load event of this page, I have added 3 sub menus -a1,a2,a3 to "A"   [ testMenu.Items[0].Items.Add(new RadMenuItem("a1")); testMenu.Items[0].Items.Add(new RadMenuItem("a4")); testMenu.Items[0].Items.Add(new RadMenuItem("a3"));]

  . No issues till now... now trying to get the total sub menus under "A"   from content page load event using [ (RadMenu )Master.FindControl("testMenu") ).Items[0].Items.Count] , returns '0' always  .. Can you tell me why dynamically added menu is reflected inside menu control object.

Regards
Madhu

1 Answer, 1 is accepted

Sort by
0
Kevin
Top achievements
Rank 2
answered on 15 Dec 2012, 02:36 PM
Hello Madhu,

The reason the content page shows zero is because the load event of the page always happens before the load event of the master page. You will either need to add your menu items during the master page's Init event or handle the PreRender event of the content page.

I hope that helps.
Tags
Menu
Asked by
Madhu
Top achievements
Rank 1
Answers by
Kevin
Top achievements
Rank 2
Share this question
or