locked
Preventing Menu Levels from showing up RRS feed

  • Question

  • User-727466326 posted

    I've been playing with the latest version of ASP.NET 2.0 CSS Friendly Control Adapters 1.0.  I want to only display the first level of the menu, just Music and movies without the submenus.  Essentially, I want to prune away all levels except for the first one. I've tried setting the DynamicDisplayLevels and the StaticDisplayLevels and it doesn't do anything.  I heard a while back that display levels were implemented.  Is there anything I can do at the datasource level?

    Also, what's the difference between these StaticDisplayLevels and DynamicDisplayLevels?  The differences seem vague from the documentation I've read.


    Thursday, January 17, 2008 9:31 PM

Answers

  • User519337647 posted

    Displaying just the right levels of the menu requires coordination between the menu control, the SiteMapDataSource, and your web.sitemap.

    First, static display levels refer to the levels you can see just looking at the page.  The dynamic levels are the ones that you would see as drop-down items when you mouse over their static "parent." 

    If you had a web.sitemap like this:

    <?xml version="1.0" encoding="utf-8" ?><siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0" >
    <siteMapNode url="~/" title="Home" description="">

    <siteMapNode url="~/about.aspx" title="About Us" description="" >

     <siteMapNode url="~/ourteam.aspx" title="Meet Our Team" description="" />

    </siteMapNode>

    <
    siteMapNode url="~/contact.aspx" title="Contact Us" description="" />

    </siteMapNode>

    </siteMap>

    ...then then there are three levels to the sitemap, the home page on the first, about and contact on the second, and ourteam on the third, as a "child" of about.

    If you wanted to see home, about, and contact, and nothing else, you could set the following:

    On the SiteMapDataSource:

    ShowStartingNode="True" (this is a default actually and you would not have to set it)

    On the Menu control:

    StaticDisplayLevels="2"

    MaximumDynamicDisplayLevels="0"

    I think those settings alone would make it work that way. Hopefully this simple example explains a little.  If you want to, you could post the markup of your menu, sitemapdatasource, and web.sitemap and I could offer more relevant descriptions.

    Maybe try this tutorial for a more complete discussion: http://msconline.maconstate.edu/tutorials/ASPNET20/default.htm. Scroll down to section 12 to find the menu control info

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, January 18, 2008 3:09 AM