- Sitemap Web Server Control
In ASP.NET environment,This article describes you how to work with Sitemap Web Control.The
primary purpose of the Sitemap Web Control can be used to provide the Naviation
Path.moreover, The SiteMapPath displays a navigation path that shows the user the
current page location and displays links as a path back to the home page. The control
provides many options for customizing the appearance of the links.
The SiteMapPath control can get the navigation data from a site map. The information
such as WebsiteURL,Title can be shown through this Web Control. Storing your navigation
data in one place makes it easier to add and remove items in the navigational menus
of your Web site.
The following code snippets represents the site-map data from a Web.sitemap file.
-
<sitemap>
<siteMapNode title="Home" description="Home" url="~/default.aspx" >
<siteMapNode title="Details" description="Details"
url="~/Details.aspx">
<siteMapNode title="Profile" description="Profile"
url="~/Profile.aspx" />
<siteMapNode title="Contact" description="Contact"
url="~/Contact.aspx" />
</siteMapNode>
</siteMapNode>
</sitemap>
-
Then the above example can looks like follwing,
Home > Details > Profile
-
- Appearance of SiteMapPath
This control includes the following customization features of the SiteMapPath Web
server control:
- Specify characters or images that display between the links.
- Reverse the direction of the navigation path.
- Specify the number of parent links that are displayed.
To customize link style properties
- In .aspx file, Includes the following properties to the Sitemap control:
-
<asp:SiteMapPath ID="SiteMapPath1" Runat="server"
SkipLinkText="Skip Menu"
RootNodeStyle-Font-Names="Verdana"
RootNodeStyle-ForeColor="Red"
RootNodeStyle-BorderWidth=1px >
</asp:SiteMapPath>
-
- If you want the style of each link to be different, repeat the previous step with
the ParentNodeStyle, CurrentNodeStyle, and PathSeperatorStyle properties of the
SiteMapPath control.
To customize a character that displays between links
the following example represents the way to customize it
-
<asp:SiteMapPath ID="SiteMapPath1" Runat="server"
PathSeparator=" = ">
</asp:SiteMapPath>
-
Then, the output looks like,
Home = Details = Profile
To specify an image that displays between links
In an ASP.NET Web page that contains a SiteMapPath control, add the following lines
of code to the control:
-
<asp:SiteMapPath ID="SiteMapPath1" Runat="server" >
<PathSeparatorTemplate>
<asp:Image ID="Image1" Runat="Server"
Width="20"
ImageUrl="Images/img1.jpg" />
</PathSeparatorTemplate>
</PathSeparatorTemplate>
</asp:SiteMapPath>
-
- To specify an image that displays between links
In an ASP.NET Web page that contains a SiteMapPath control, add the following lines
of code to the control:
- In an ASP.NET Web page that contains a SiteMapPath control, add the ParentLevelsDisplayed
property to the control.
The following example represents the above purpose
-
<asp:SiteMapPath ID="SiteMapPath1" Runat="server"
ParentLevelsDisplayed="3" >
</asp:SiteMapPath>
-
- Related Links
-
cb8ef958-0a1b-4772-bda2-e8448f79bcc8|0|.0