WEBINAR: On-demand webcast
How to Boost Database Development Productivity on Linux, Docker, and Kubernetes with Microsoft SQL Server 2017 REGISTER >
As far as I know, before ASP .NET 2.0, there was not a system of website navigation controls to speak of. Different websites have different navigation styles and execution methods. Many advanced websites have database or XML files for content/navigation management; the others, especially the less dynamic ones, still have hard-coded navigation links. Some websites use topdown menus, some use sidebars; some use collapesable tree menus, some have bread-crumb style path information at the top of every web page. A lot of websites use a combination of all these methods.
Asthetics plays an as important role as easy navigation. Some websites build exquisite graphics for every menu item, whereas others employ elaborate style sheets. After all, smooth and appealing navigation to a website equals good communication skills, and that's an asset to a person's career.
Now, with the introduction of the new navigation controls of ASP .NET 2.0, building a navigation system for a complicated website becomes a systematic, easy-to-manage process.
The following section shows you how to use the three navigation controls in ASP .NET 2.0: TreeView, Menu, and SiteMapPath.
Create a web.sitemap File
The foundation upon which the three navigation controls rested is an XML file called web.sitemap that maps the structure of a website. It resides in the application's root directory. The SiteMap file has two elements: siteMap and siteMapNode. The SiteMap element is the root element; it can have unlimited nested sitemap nodes to mirror a website's hierarchy, but it can have only one top-level SiteMapNode designated for the home page. Each SitemapNode must have one unique URL, so no page can appear in the website more than once. The common attributes of a SiteMapNode are URL, description, title, and role. The last attribute, "role," is used to indicate a page's accessibility because not all pages are created nor treated equal. For example, you probably would want to hide all admin pages from public eyes.
To create a SiteMap file, choose the Web Site -> Add New File command. You also may start a new file, select its page type as a SiteMap file from the list of file options, and name it web.sitemap.
So, for a simple website that has the structure diagramed as the following:
the web.sitemap file would look like this:
<?xml version="1.0" encoding="utf-8" ?> <siteMap xmlns="http://schemas.microsoft.com/AspNet/ SiteMap-File-1.0" > <siteMapNode url="Default.aspx" title="Home" description="Welcome to ASP .NET home"> <siteMapNode url="About.aspx" title="About Us" description="" > <siteMapNode url="Histroy.aspx" title="History" description="" /> <siteMapNode url="Contact.aspx" title="Contact Us" description="" /> </siteMapNode> <siteMapNode url="Research.aspx" title="Research" description="" /> <siteMapNode url="" title="Publications" description="" > <siteMapNode url="Current.aspx" title="History" description="" > <siteMapNode url="Art.aspx" title="Arts and Culture" description="" /> <siteMapNode url="Qol.aspx" title="Qaulity of Life" description="" /> </siteMapNode> <siteMapNode url="Archive.aspx" title="Contact Us" description="" /> </siteMapNode> </siteMapNode> </siteMap>
With the SiteMap file created, you now are ready to use the three navigation controls.