Professional Documents
Culture Documents
objectives
The basics of site navigation in ASP.NET
Creating and defining your website’s structure
Showing the user’s current location in the site’s structure using a breadcrumb
Displaying the site’s structure using the TreeView Web control
Using the Menu Web control
1|Page
The site map file is an XML file that expresses the logical structure of the website.
XML documents impose strict formatting rules. For instance, XML is case sensitive. All
elements must have opening and closing tags.
2|Page
Each <siteMapNode> element must contain a title attribute; the url and description attributes are
optional. Furthermore, each provided url attribute must be unique. You cannot have two
<siteMapNode> elements with the same url value.
The completed site map contents
<?xml version=”1.0” encoding=”utf-8” ?>
3|Page
Add the SiteMapPath control to the Default.aspx pages in the root directory, in the Technology
folder, and the Computers subfolder. From the designer, the SiteMapPath control shows the
layout based on the values in the site map and the page’s location in the site map.
4|Page
structure hierarchy. Each node in the tree is rendered as a hyperlink that, when clicked, whisks
the user to the appropriate section.
Let’s add a TreeView to the Home section (Default.aspx in the root folder). To do so, we must
first add a SiteMapDataSource control to the page; this control can be found in the Data section
of the Toolbox.
Next, add the TreeView control to the page and, from its smart tag, select the
SiteMapDataSource we just added to the page from the Choose Data Source drop-down list.
Once the data source has been specified, the TreeView control’s appearance in the designer is
updated, mirroring the hierarchy expressed in site map.
5|Page
Let’s add a Menu control to the Default.aspx page in the Fiction folder. Start by adding a
SiteMapDataSource control; next, add the Menu control and bind it to the SiteMapDataSource
control. After the data source is specified, the Menu’s appearance in the designer is updated to
reflect the structure of the site map. By default, the menu shows just the top-level element in the
site map hierarchy—Home, for our site map.
6|Page