Wednesday, August 11, 2010

How to occupy multiple site map files in a single website in asp.net

There are some occations where we need to provide two menu structures. For example top navigation and left navigation. In such cases we can easily configure two XML Sitemap providers in web.config and use them separately in the asp.net pages
Web.config
<siteMap>
  <providers>
    <add siteMapFile="topNavigation.sitemap" name="TopNavigationSiteMapProvider"
        type="System.Web.XmlSiteMapProvider, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
    <add siteMapFile="leftNavigation.sitemap" name="leftNavigationSiteMapProvider"
        type="System.Web.XmlSiteMapProvider, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
  </providers>
</siteMap>

Markup
<asp:SiteMapDataSource ID="smdTopNavigation" SiteMapProvider="TopNavigationSiteMapProvider" runat="server" />
<asp:Menu runat="server" ID="mnuTopNavigation" DataSourceID="smdTopNavigation" />
 
<asp:SiteMapDataSource ID="smdLeftNavigation" SiteMapProvider="LeftNavigationSiteMapProvider" runat="server" />
<asp:Menu runat="server" ID="menuLeftNavigation" DataSourceID="smdLeftNavigation" />

No comments:

Azure Storage Account Types

Defferent Types of Blobs Block blobs store text and binary data. Block blobs are made up of blocks of data that can be managed individually...