Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • SiteMap in asp.net

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 515
    Comment on it

    In this blog I will explain you how to use siteMap in asp.net web application.I would like to start with few basic question:-

    1) What is siteMap?

    The SiteMap displays a list of links representing the user's current page and the hierarchical path back to the root of the website.

    2) Why we use siteMap?

    SiteMaps can store the all menus in a file to make it easier to maintain. This file is called web.sitemap and is stored in the root directory of the web.

    To implement the siteMap please follow the below step:--

    Step 1:- Create a asp.net website.

    Step 2:- After creating asp.net website you can add some more pages and give names like:-- Home.aspx,Profile.aspx,Account.aspx and Setting.aspx

    Step 3:- Once page added on the website is done then you need to add the sitemap control on his website.

    Right click on website and select Add New Item >> Select SiteMap >> OK

    Once SiteMAP added to your website open SiteMAP you will find the below code snippet:----

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

    Now You need to add your page name on each siteMapNode.

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

    In above sitemap I added Profile.aspx,Account.aspx and Setting.aspx pages under Home.aspx page.

    If we are using master page in your application then we need to put siteMap control in master page.Other wise we need to add siteMap control in all pages.( Home.aspx,Profile.aspx,Account.aspx and Setting.aspx)

    code snippet:---
     <asp:SiteMapDataSource ID="SiteMapDataSource1" runat="server" />
     <asp:SiteMapPath ID="SiteMap1" runat="server"></asp:SiteMapPath>
    

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: