First, Introduction
Any web site made up of multiple pages requires some sort of navigation user interface. A navigation user interface may be as simple as some static hyperlinks to other pages in the site, or it may contain the use of a menu or tree control. However, before you create a navigation user interface for the site, you must first define the logical structure of the site. (This logical structure is often referred to as a site map.) For example, a site like Amazon.com is organized into parts-including product bars such as electronics books, computer books, DVDs, and so on. Each of these may also contain a child part. The bibliography is divided by type, like CD, novel, History book, romantic book class, etc. Typically, these logical structures form a hierarchy of classifications. The screenshot below shows a thumbnail version of the Amazon.com site map.
Once you have defined your site map, you can create a navigation user interface for your site. At the Amazon.com site, the main page lists hyperlinks to each of the sections on the left side of the page. After you enter a specific section, the child information for that part is displayed on the left. However, you can also use a different navigation user interface: You might have a tree that displays parts and sections, or a menu that lists items such as books, electronic products, DVDs, and so on, and a submenu of each menu item contains a subset of the parts.
Before ASP.net 2.0, developers typically solved their site navigation capabilities. However, ASP.net 2.0 makes it easy to define the structure of a site and implement it with the common navigation user interface elements. In this article, we will analyze the site navigation features of ASP.net 2.0.
Second, ASP.net 1.x era of site navigation
asp.net version 1.x does not provide any built-in site navigation support, so most developers implement their own site navigation capabilities. When creating their own site navigation capabilities, developers face two challenges:
1. Decide how to serialize the site's structure information to a site map
2. Implement navigation user interface elements
To solve the first problem, developers need to decide how to model the structure of the site. Do you want to put this information in an XML file? Or do you want to add a database table to store parts of your site and how to contact it? For sites that support user accounts, there may be an accessible portion only for users belonging to special roles. Also, a site that supports multiple languages needs to provide translations for individual site segments in some way.
Determine what information needs to be stored to describe the structure of the site and how that information is serialized (database? XML file? Other things? Later, developers face a second challenge-how to show the structure of the site to the user. A commonly used navigation user interface element is a menu; however, the ASP.net 1.x does not provide a built-in menu Web control-which means that developers have to spend their money or build on their own.
Let's conclude that it's not difficult to implement site navigation in the ASP.net version 1.x, but this is another task that has to be done. And since there is no built-in support for site navigation, each developer may find his own unique approach, which increases the steep level of development novice learning curve-they must learn custom site navigation logic.
Three, ASP.net 2.0 of the site navigation
It's easy to implement site navigation in ASP.net 2.0, thanks to building site navigation features. Internally, ASP. NET provides a set of programmable api-that can be used for site map queries. Asp. NET does not need to provide a special format for the specified site map, although it does provide a default choice for using XML-formatted files. Details on how to serialize the site map can be customized because the site navigation features of ASP.net 2.0 use a provider model. The provider model enables developers to customize a specific ASP. The internal implementation of the net sub-system-as long as they keep the APIs referenced forward are the same.
In short, you can use the default xml-based method of ASP.net 2.0 to specify the site map of your site, or just add a little coding, and you can use existing custom methods, or some other methods. (This article will discuss using the default technology (based on XML and site map); The next article in this system will analyze how to customize the site navigation provider. )
In addition to providing a customizable means to specify the site structure, there are also navigation Web controls that are shipped with ASP.net 2.0-they make the display of Sitemap as easy as dragging a control to your asp.net page:
1. sitemappath-displays a breadcrumb that shows where the end user is in relation to the site structure. For example, when you visit the novels section of the Amazon.com site, a breadcrumb display might look like this: Home>books>novels.
2. treeview-displays the structure of the site with an expandable tree.
3. menu-uses a menu to display the structure of the site.
4. When displaying site navigation, both the TreeView control and the menu control use the SiteMapDataSource control to read the contents of the site map.
On the underlying implementation, these controls invoke the site navigation API for ASP.net 2.0. Now that the site Navigation section is implemented with the provider model, it is easy to understand how the control will serialize the internal implementation of the site map. That is, whether you use the default sitemap or roll your own custom site map logic, navigation controls can be used to work with your site map. (assuming that if you want to use a custom site map, you do need to create a class-it provides the methods and attributes you want to work with the site map; The next article is discussed in more detail).