Hide root node only for Menu control

Last post 10-01-2008 5:46 PM by benditobernard. 6 replies.

Sort Posts:

  • Hide root node only for Menu control

    10-17-2005, 1:34 PM
    • Participant
      905 point Participant
    • craigt-from-atl
    • Member since 06-18-2002, 4:41 PM
    • Atlanta
    • Posts 217
    I've been having some issues trying to hide my root node in my Menu control.  My different combinations of "ShowStartingNode" and "StartingNodeOffset" seem to either hide the entire menu or just take out the root nodes for each branch.

    I have a structure similar to this:

    Home
    --User
    ----UserPage1
    ----UserPage2
    --Stuff
    ----StuffPage1
    ----StuffPage2
    --More Stuff
    ----MoreStuffPage1
    ----MoreStuffPage2

    In my menu control I would like to see "User", "Stuff" and "More Stuff" as menu options.  Then these will have the fly-out menus for the sub pages.  I just want to remove "Home" from the menu control.

    Is there some easy way to do this that I'm just not seeing?  I've been attempting things like getting a reference to the menu control at run-time and attempting to loop through the MenuItemCollection in an attempt to rebuild it w/out the Home node.  I have been unsuccessful to this point.

    Any ideas?  Thanks!

    -Craig

    U-Sports.net - Taking Fantasy Football to School
  • Re: Hide root node only for Menu control

    10-17-2005, 5:29 PM
    • Participant
      1,140 point Participant
    • tinghaoy
    • Member since 06-11-2002, 2:29 PM
    • Beijing, China
    • Posts 228
    • AspNetTeam
    You can achieve it by simply setting the ShowStartingNode="false" on the datasource control. For example:

    <asp:Menu ID="Menu1" runat="server" DataSourceID="SiteMapDataSource1">

    </asp:Menu>

    <asp:SiteMapDataSource ID="SiteMapDataSource1" runat="server" ShowStartingNode="False" />


    HTH,
    Ting-hao
    This posting is provided "AS IS" with no warranties, and confers no rights.
  • Re: Hide root node only for Menu control

    10-17-2005, 5:50 PM
    • Participant
      905 point Participant
    • craigt-from-atl
    • Member since 06-18-2002, 4:41 PM
    • Atlanta
    • Posts 217

    Setting "ShowStartingNode=False" has the effect of flattening my entire directory structure.

    It makes my above directory structure look like this:
    User  UserPage1  UserPage2  Stuff  StuffPage1  StuffPage2  More Stuff  MoreStuffPage1  MoreStuffPage2

    I would like it to look like this: (with the subpages appearing when I hover over the respective directories)
    User  Stuff  More Stuff

    Is "ShowStartingNode=false" supposed to remove only the root node and leave the rest of the structure intact?

    Thanks.

    -Craig

    U-Sports.net - Taking Fantasy Football to School
  • Re: Hide root node only for Menu control

    10-17-2005, 7:51 PM
    • Participant
      880 point Participant
    • JoeBerg
    • Member since 08-20-2004, 1:08 PM
    • Redmond
    • Posts 176
    Hi Craig, this shouldn't be the case. In your output, it looks like the Menu control has StaticDisplayLevels set to "2". Please can you provide the code for your sitemap file as well as your markup for the Menu?

    Thanks,
    Joe
  • Re: Hide root node only for Menu control

    10-18-2005, 10:20 AM
    • Participant
      905 point Participant
    • craigt-from-atl
    • Member since 06-18-2002, 4:41 PM
    • Atlanta
    • Posts 217
     JoeBerg wrote:
    Hi Craig, this shouldn't be the case. In your output, it looks like the Menu control has StaticDisplayLevels set to "2". Please can you provide the code for your sitemap file as well as your markup for the Menu?

    Thanks,
    Joe


    Exactly correct! Wink [;)]

    I think I had a misunderstanding as to the purpose of "StaticDisplayLevels."  Been doing a bit more reading and think I understand it better now.  Removing the "StaticDisplayLevels" attribute alltogether fixed it!

    Thanks for your patience and time!

    -Craig

    U-Sports.net - Taking Fantasy Football to School
  • Re: Hide root node only for Menu control

    08-28-2008, 2:04 AM
    • Member
      77 point Member
    • sujithmysore
    • Member since 04-30-2007, 5:33 AM
    • Posts 41

    Changing the Showstarting node = false worked very well for me... many thnx for ur very useful tip..

    cheers

  • Re: Hide root node only for Menu control

    10-01-2008, 5:46 PM

    This works thanks

Page 1 of 1 (7 items)