Horizontal tabbed menu and sitemap

Last post 09-11-2007 3:31 PM by static_-x-_. 2 replies.

Sort Posts:

  • Horizontal tabbed menu and sitemap

    09-11-2007, 6:56 AM
    • Member
      1 point Member
    • static_-x-_
    • Member since 09-11-2007, 5:34 AM
    • Posts 7

    My Web App contains a main navigation bar at the top of all pages, placed in a master page of course, (that looks and functions exactly like - http://www.exploding-boy.com/images/cssmenus/menus.html). However I am having difficulty in integrating a sitemap. Does anyone know if this is possible? (I have searched the net with no such luck).

     

    the alternative is to hard-code the menu, however I do not really want to do this, as I will lose the functionality of the sitemap (for example, security).

     

    As anyone attempted to do this before? if so please provide anything that may help, cheers!

  • Re: Horizontal tabbed menu and sitemap

    09-11-2007, 7:32 AM
    Answer
    • Contributor
      4,219 point Contributor
    • moredotnet
    • Member since 11-24-2006, 12:07 PM
    • Millenium City
    • Posts 780

    Here is what u need to do...

    Create a menu...set the following properties...

    Orientation="Horizontal" DataSourceID="menu_SiteMapDataSource" 

    Immediately after the menu control...add this... 

     

    <asp:SiteMapDataSource ID="menu_SiteMapDataSource"

    runat="server" SiteMapProvider="myMenuSiteMap" />

     

    Next... 

    We need to register this sitemapprovider in our web.config, so add this piece of code out there too…

     

    <system.web>

      <siteMap defaultProvider="XmlSiteMapProvider" enabled="true">

          <providers>

            <clear />       

            <add

             name="myMenuSiteMap"

             description="Menu SiteMap provider"

             type="System.Web.XmlSiteMapProvider"

             siteMapFile="~/mysite.sitemap" />

          </providers>

        </siteMap>

    </system.web>   

     

    As we see above, the data in the menu is saved in a file called mysite.sitemap located on the root folder itself. To create a sitemap, right click your project, add new item, select Site Map. Here is how the sitemap file looks like…

     

      
     

    <?xml version="1.0" encoding="utf-8" ?>

    <!-- SITEMAP FILE FOR MENU CONTROL-->

    <siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0" >

      <siteMapNode url="~/myfolder/home.aspx" title="Home"  description="">

    <siteMapNode url="~/myfolder/services.aspx" title="Services"   description="" />     

    <siteMapNode url="~/myfolder/products" title="Products"  description="" />

    <siteMapNode url="~/myfolder /aboutus.aspx" title="About Us"  description="" />   <siteMapNode url="~/myfolder/contactus.aspx" title="Contact Us"  description="" />

                                                                         

    </siteMapNode>

    </siteMap>

    Note that there are 2 levels out of data out here, and hence we have the property StaticDisplayLevels="2" for the menu control.

     HTH

    Cheers

    Vishal Khanna

    (pls mark as answer if reply helps)

    Vishal Khanna



    ASP.NET|C#|AJAX|SQL|Design Patterns|Interview FAQs
  • Re: Horizontal tabbed menu and sitemap

    09-11-2007, 3:31 PM
    • Member
      1 point Member
    • static_-x-_
    • Member since 09-11-2007, 5:34 AM
    • Posts 7

     Thank you, the above code worked like a charm!

     

    Please note*: I got a compile error on line <siteMap defaultProvider="XmlSiteMapProvider"  enabled="true">  in the Web.config file, all you need to do is change this to <siteMap defaultProvider="myMenuSiteMap"  enabled="true"> and it should compile with no problems.

Page 1 of 1 (3 items)