Issue with dynamically added menu

2 posts, 0 answers
  1. Madhu
    Madhu avatar
    8 posts
    Member since:
    Jul 2010

    Posted 15 Dec 2012 Link to this post

      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.

  2. Kevin
    Kevin avatar
    360 posts
    Member since:
    Jul 2012

    Posted 15 Dec 2012 Link to this post

    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.
  3. DevCraft R3 2016 release webinar banner
Back to Top