Question

I am trying to add breadcrumbs on my web pages for easy navigation. For this I am using SiteMapPath Control of Asp.Net and along with this I have also made a breadcrumb.Sitemap file which list all the pages. But While implementing the sitemappath in my master page, I am getting a generic error. I am not able to understand why is this happening? This is the basic structure of my aspx page-

<div id="menu-pt">
<div class="hm"><a href="Page1.aspx" class="active">Home</a></div>
<div id="nav">
<ul id="nav" name="nav">
                <li><a href="Page2.aspx">Page2</a></li>
                <div class="saparation"></div>
                <li><a href="Page3.aspx">Page3</a></li>
                <div class="saparation"></div>
             <li> <a href="Page4.aspx">Page4</a></li>
            <div class="saparation"></div>
            <li><a href="#">Pages</a>
            <div id ="Ul2" runat="server">
                <ul id="sub-nav" >
                <li><a href="Page5.aspx">Page5</a></li>
                <li><a href="Page6.aspx">Page6</a></li>
                <li><a href="Page7.aspx">Page7</a></li>
                <li><a href="Page8.aspx">Page8</a></li>
            </ul>
            </div>
             <div id ="Ul1" runat="server">
             <ul id="sub-nav" >

                <li><a href="Page9.aspx">Page9</a></li>
                <li><a href="Page10.aspx">Page10</a></li>
                <li><a href="Page11.aspx">Page11</a></li>
                <li><a href="Page12.aspx">Page12</a></li>
                <li><a href="Page13.aspx">Page13</a></li>
            </ul>
            </div>
                </li>          
           </ul>
</div>
</div>

  • Page5,6,7,8.aspx pages is for all users. And
  • Page9,10,11,12,13.aspx pages are for logged in user. And My breadcrumb.sitemap file is-

    <?xml version="1.0" encoding="utf-8" ?>
    <siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0" >
        <siteMapNode url="Page1.aspx" title="Home"  description="Page1">
            <siteMapNode url="Page2.aspx" title="Page2"  description="Page2" />
            <siteMapNode url="Page3.aspx" title="Page3"  description="Page3" />
          <siteMapNode url="Page4.aspx" title="Page4"  description="Page4" />
          <siteMapNode url="" title="Pages"  description="">
            <siteMapNode url="Page5.aspx" title="Page5"  description="Page5" />
            <siteMapNode url="Page6.aspx" title="Page6"  description="Page6" />
            <siteMapNode url="Page7.aspx" title="Page7"  description="Page7" />
            <siteMapNode url="Page8.aspx" title="Page8"  description="Page8" />
            <siteMapNode url="Page9.aspx" title="Page9"  description="Page9" />
            <siteMapNode url="Page10.aspx" title="Page10"  description="Page10" />
            <siteMapNode url="Page11.aspx" title="Page11"  description="Page11" />
            <siteMapNode url="Page12.aspx" title="Page12"  description="Page12" />
            <siteMapNode url="Page13.aspx" title="Page13"  description="Page13" />
          </siteMapNode>
        </siteMapNode>
    </siteMap>
    

    Also I have placed a sitemappath control on my aspx page-

    <asp:SiteMapPath ID="SiteMapPath1" runat="server"></asp:SiteMapPath>
    

    Please guide me where I am doing wrong. I read few articles and it says that this much of step is enough for adding breadcrumbs on every pages of a web site. Please Guide me where I am doing Wrong?

  • Was it helpful?

    Solution

    The SiteMapPath control uses the Web.sitemap file by default. Also, place the sitemap file in the root directory of the website and the URL attributes should be relative to the root directory.

    Also the page you are trying to view must be included in the sitemap file else NO breadcrumb will show up on this page.

    EDIT::

    Make sure you include the SiteMapPath control on master page, so that it will be available for all your pages from Page1.apsx to Page13.aspx ( In case they all use a master file ), else you should place the SiteMapPath control individually on every page where you need to display the breadcrumb.

    Also you mentioned your sitemap file as breadcrumb.sitemap, just make sure it should be Web.sitemap. If it is already Web.sitemap, leave it.

    Just tried your code and breadcrumb is displayed properly.[ Top left corner ]. In my case the SiteMapPath control was placed on master file.

    enter image description here

    Licensed under: CC-BY-SA with attribution
    Not affiliated with StackOverflow
    scroll top