asp.net sitemap navigation simplified

First you create a Web.sitemap file (similar to below)
(I save mine in my App_Data Folder -right click add new ASP.Net Folder -> App_Data)

<?xml encoding="utf-8" version="1.0" ?>
<sitemap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0">
    <siteMapNode title="Main" description="login" url="~/login.aspx" roles="*" >
        <siteMapNode title="Admin" description="here" url="~/Admin/home.aspx" >
            <siteMapNode title="Reports" description="reports" url="~/Admin/Reports.aspx" />
        <siteMapNode title="Lab" description="here" url="~/lab/home.aspx" roles="lab" />
    <siteMapNode ...... />
    <siteMapNode ...... />

Please note how I have nested the Reports under the Admin tab.


If you use a SiteMapDataSource the first thing you probably want to do is to add the ShowStartingNode=”false”element to the tag.
In my case it would prevent showing the “Main” menu item (which I don’t want – and you probably too)
The following tag should be on the page where you want the Menu (probably your master page)

<asp:SiteMapDataSource ShowStartingNode="false" runat="server"
ID="sitemapdatasource1" SiteMapProvider="default" />

Make sure you set Orientation element in your "asp:Menu" tag to "Horizontal.

Also try to set the "StaticEnableDefaultPopOutImage" element in your "asp:Menu" tag to ="false"   (this will stop the tips that point out which menus are expandable)

 Thus my tag looks as follows:

<asp:Menu ID="mnuMain" runat="server" DataSourceID="sitemapdatasource1"
 StaticEnableDefaultPopOutImage="false" Orientation="Horizontal" >

What's your thoughts on this?


Protected by WP Anti Spam