ASP.NET 2.0数据教程之三:母板页和站点导航
[1] ASP.NET 2.0数据教程之三:母板页和站点导航
[2] ASP.NET 2.0数据教程之三:母板页和站点导航
[3] ASP.NET 2.0数据教程之三:母板页和站点导航
[4] ASP.NET 2.0数据教程之三:母板页和站点导航
[5] ASP.NET 2.0数据教程之三:母板页和站点导航
[6] ASP.NET 2.0数据教程之三:母板页和站点导航
[7] ASP.NET 2.0数据教程之三:母板页和站点导航
[8] ASP.NET 2.0数据教程之三:母板页和站点导航
[9] ASP.NET 2.0数据教程之三:母板页和站点导航
[10] ASP.NET 2.0数据教程之三:母板页和站点导航
[11] ASP.NET 2.0数据教程之三:母板页和站点导航
[12] ASP.NET 2.0数据教程之三:母板页和站点导航
[13] ASP.NET 2.0数据教程之三:母板页和站点导航
[2] ASP.NET 2.0数据教程之三:母板页和站点导航
[3] ASP.NET 2.0数据教程之三:母板页和站点导航
[4] ASP.NET 2.0数据教程之三:母板页和站点导航
[5] ASP.NET 2.0数据教程之三:母板页和站点导航
[6] ASP.NET 2.0数据教程之三:母板页和站点导航
[7] ASP.NET 2.0数据教程之三:母板页和站点导航
[8] ASP.NET 2.0数据教程之三:母板页和站点导航
[9] ASP.NET 2.0数据教程之三:母板页和站点导航
[10] ASP.NET 2.0数据教程之三:母板页和站点导航
[11] ASP.NET 2.0数据教程之三:母板页和站点导航
[12] ASP.NET 2.0数据教程之三:母板页和站点导航
[13] ASP.NET 2.0数据教程之三:母板页和站点导航
系列文章导航:
ASP.NET 2.0数据教程之四:使用ObjectDataSource展现数据
ASP.NET 2.0数据教程之六:编程设置ObjectDataSource的参数值
ASP.NET 2.0数据教程之七:使用DropDownList过滤的主/从报表
ASP.NET 2.0数据教程之八:使用两个DropDownList过滤的主/从报表
ASP.NET 2.0数据教程之十:使用 GridView 和DetailView实现的主/从报表
ASP.NET 2.0数据教程之十一:基于数据的自定义格式化
ASP.NET 2.0数据教程之十二:在GridView控件中使用TemplateField
站点地图模拟了文件系统。为每个文件夹添加一个<siteMapNode>元素,并且为每个aspx页面添加一个<siteMapNode>子元素,如此:
Web.sitemap:
1<?xml version="1.0" encoding="utf-8" ?>
2<siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0" >
3
4 <siteMapNode url="~/Default.aspx" title="Home" description="Home">
5 <siteMapNode title="Basic Reporting"
6 url="~/BasicReporting/Default.aspx"
7 description="Basic Reporting Samples">
8 <siteMapNode url="~/BasicReporting/SimpleDisplay.aspx"
9 title="Simple Display"
10 description="Displays the complete contents
11 of a database table." />
12 <siteMapNode url="~/BasicReporting/DeclarativeParams.aspx"
13 title="Declarative Parameters"
14 description="Displays a subset of the contents
15 of a database table using parameters." />
16 <siteMapNode url="~/BasicReporting/ProgrammaticParams.aspx"
17 title="Setting Parameter Values"
18 description="Shows how to set parameter values
19 programmatically." />
20 </siteMapNode>
21
22 <siteMapNode title="Filtering Reports"
23 url="~/Filtering/Default.aspx"
24 description="Samples of Reports that Support Filtering">
25 <siteMapNode url="~/Filtering/FilterByDropDownList.aspx"
26 title="Filter by Drop-Down List"
27description="Filter results using a drop-down list." />
28 <siteMapNode url="~/Filtering/MasterDetailsDetails.aspx"
29 title="Master-Details-Details"
30 description="Filter results two levels down." />
31 <siteMapNode url="~/Filtering/DetailsBySelecting.aspx"
32 title="Details of Selected Row"
33description="Show detail results for a selected item in a GridView." />
34 </siteMapNode>
35
36 <siteMapNode title="Customized Formatting"
37 url="~/CustomFormatting/Default.aspx"
38 description="Samples of Reports Whose Formats are Customized">
39 <siteMapNode url="~/CustomFormatting/CustomColors.aspx"
40 title="Format Colors"
41 description="Format the grid's colors based
42 on the underlying data." />
43 <siteMapNode
44 url="~/CustomFormatting/GridViewTemplateField.aspx"
45 title="Custom Content in a GridView"
46 description="Shows using the TemplateField to
47 customize the contents of a field in a GridView." />
48 <siteMapNode
49 url="~/CustomFormatting/DetailsViewTemplateField.aspx"
50 title="Custom Content in a DetailsView"
51 description="Shows using the TemplateField to customize
52 the contents of a field in a DetailsView." />
53 <siteMapNode url="~/CustomFormatting/FormView.aspx"
54 title="Custom Content in a FormView"
55 description="Illustrates using a FormView for a
56 highly customized view." />
57 <siteMapNode url="~/CustomFormatting/SummaryDataInFooter.aspx"
58 title="Summary Data in Footer"
59 description="Display summary data in the grids footer." />
60 </siteMapNode>
61
62 </siteMapNode>
63
64</siteMap>
2<siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0" >
3
4 <siteMapNode url="~/Default.aspx" title="Home" description="Home">
5 <siteMapNode title="Basic Reporting"
6 url="~/BasicReporting/Default.aspx"
7 description="Basic Reporting Samples">
8 <siteMapNode url="~/BasicReporting/SimpleDisplay.aspx"
9 title="Simple Display"
10 description="Displays the complete contents
11 of a database table." />
12 <siteMapNode url="~/BasicReporting/DeclarativeParams.aspx"
13 title="Declarative Parameters"
14 description="Displays a subset of the contents
15 of a database table using parameters." />
16 <siteMapNode url="~/BasicReporting/ProgrammaticParams.aspx"
17 title="Setting Parameter Values"
18 description="Shows how to set parameter values
19 programmatically." />
20 </siteMapNode>
21
22 <siteMapNode title="Filtering Reports"
23 url="~/Filtering/Default.aspx"
24 description="Samples of Reports that Support Filtering">
25 <siteMapNode url="~/Filtering/FilterByDropDownList.aspx"
26 title="Filter by Drop-Down List"
27description="Filter results using a drop-down list." />
28 <siteMapNode url="~/Filtering/MasterDetailsDetails.aspx"
29 title="Master-Details-Details"
30 description="Filter results two levels down." />
31 <siteMapNode url="~/Filtering/DetailsBySelecting.aspx"
32 title="Details of Selected Row"
33description="Show detail results for a selected item in a GridView." />
34 </siteMapNode>
35
36 <siteMapNode title="Customized Formatting"
37 url="~/CustomFormatting/Default.aspx"
38 description="Samples of Reports Whose Formats are Customized">
39 <siteMapNode url="~/CustomFormatting/CustomColors.aspx"
40 title="Format Colors"
41 description="Format the grid's colors based
42 on the underlying data." />
43 <siteMapNode
44 url="~/CustomFormatting/GridViewTemplateField.aspx"
45 title="Custom Content in a GridView"
46 description="Shows using the TemplateField to
47 customize the contents of a field in a GridView." />
48 <siteMapNode
49 url="~/CustomFormatting/DetailsViewTemplateField.aspx"
50 title="Custom Content in a DetailsView"
51 description="Shows using the TemplateField to customize
52 the contents of a field in a DetailsView." />
53 <siteMapNode url="~/CustomFormatting/FormView.aspx"
54 title="Custom Content in a FormView"
55 description="Illustrates using a FormView for a
56 highly customized view." />
57 <siteMapNode url="~/CustomFormatting/SummaryDataInFooter.aspx"
58 title="Summary Data in Footer"
59 description="Display summary data in the grids footer." />
60 </siteMapNode>
61
62 </siteMapNode>
63
64</siteMap>
站点地图定义了这个站点的导航结构,它是层次结构的以便描述站点中各种各样的区域。在Web.sitemap中的每个<siteMapNode>元素描述了一个站点结构中的一个区域。
图10:站点地图描述了一个层次的导航结构
Asp.net通过DotNET 框架中的SiteMap类显示站点地图的结构。这个类有一个CurrentNode属性,它返回当前用户正在访问的节点的信息;RootNode属性返回站点地图的根节点信息(在我们的站点地图中是Home)。CurrentNode呵RootNode属性都返回SiteMapNode实例,SiteMapNode包含ParentNode,ChildNodes,NextSibling,PreviousSibling等属性,这些属性允许站点地图的层次可以被遍历。