Before you learn about the navigation controls, you first need to understand Site Maps. All three navigation controls use Site Maps to retrieve navigation information. A Site Map enables you to represent the navigational relationships between the pages in an application, independent of the actual physical relationship between pages as stored in the file system. Site Maps use the provider model. In the next chapter, you learn how to create custom Site Map providers to store Site Maps in custom data stores such as database tables. The examples in this chapter take advantage of the default XML Site Map provider, which enables you to store a Site Map in an XML file. By default, the navigation controls assume the existence of an XML file named Web.sitemap, which is located in the root of your application. For example, Listing 17.1 contains a simple Site Map. Listing 17.1. Web.sitemap
A Site Map file contains <siteMapNode> elements. There can be only one top-level node. In the case of Listing 17.1, the top-level node represents the website's homepage. A <siteMapNode> supports three main attributes:
Notice that the url attribute is not required. Both the Products and Services nodes do not include a url attribute because these nodes do not represent pages to which you can navigate. Each <siteMapNode> can contain any number of child nodes. In Listing 17.1, both the Products and Services nodes include two child nodes. The Site Map in Listing 17.1 represents a website that has the following folder and page structure: Default.aspx Products FirstProduct.aspx SecondProduct.aspx Services FirstService.aspx SecondService.aspx The navigational structure of a website as represented by a Site Map is not required to have any relationship to the navigational structure of a website as stored in the file system. You can create any relationship between the nodes in a Site Map that you want. |