偷偷摘套内射激情视频,久久精品99国产国产精,中文字幕无线乱码人妻,中文在线中文a,性爽19p

ASP.NET 2.0數(shù)據(jù)教程:添加站點地圖

開發(fā) 后端
本文介紹在asp.net 2.0中如何添加站點地圖。

管理一個由大量網(wǎng)頁組成的網(wǎng)站的其中一個挑戰(zhàn)是要為訪問者瀏覽網(wǎng)站提供一個捷徑。作為開始,站點的導(dǎo)航結(jié)構(gòu)必須被定義。下一步,這個結(jié)構(gòu)必須轉(zhuǎn)換成適于導(dǎo)航的用戶界面元素,比如菜單或者位置導(dǎo)航。當(dāng)有新頁面添加到站點和已有的頁面被移除的時候這個過程將要修改和校正。

在asp.net 2.0以前,開發(fā)者需要自己創(chuàng)建站點導(dǎo)航結(jié)構(gòu),維護它并且將它轉(zhuǎn)化為適于導(dǎo)航的用戶界面元素。在asp.net 2.0里,開發(fā)者可以利用非常靈活的且內(nèi)置的站點導(dǎo)航系統(tǒng)。asp.net 2.0站點導(dǎo)航系統(tǒng)允許開發(fā)者定義一個站點地圖并且提供了可以訪問這些信息的API。

默認的asp.net站點地圖提供者期望站點地圖信息存儲在xml格式的文件中。但是,建立在提供者模型上的站點導(dǎo)航系統(tǒng)是可以被擴展的以支持多種方式儲存的站點地圖。Jeff Prosise的文章,The SQL Site Map Provider You’ve Been Waiting For展示了怎樣創(chuàng)建將站點地圖存儲在SQL Server數(shù)據(jù)庫里的提供者;另外一個選擇是基于文件系統(tǒng)的站點地圖提供者。

在這個指南中,我們?nèi)匀皇褂胊sp.NET2.0里默認的站點地圖提供者。要創(chuàng)建站點地圖,在解決方案管理器里右鍵點擊項目名稱,選擇添加新項,然后選擇站點地圖類型。命名為Web.sitemap然后單擊添加按鈕,則是添加站點地圖。

向你的項目中添加站點地圖 

圖9:向你的項目中添加站點地圖

站點地圖文件是一個xml文件。注意:Visual Studio可以為站點地圖結(jié)構(gòu)提供智能感知。站點地圖文件必須含有< siteMap>作為根節(jié)點,它必須至少含有一個< siteMapNode>子節(jié)點。這個< siteMapNode>元素又可以包含任意數(shù)量的< siteMapNode>子元素。

站點地圖模擬了文件系統(tǒng)。為每個文件夾添加一個< 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" 
  27. description="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" 
  33. description="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&apos;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> 

站點地圖定義了這個站點的導(dǎo)航結(jié)構(gòu),它是層次結(jié)構(gòu)的以便描述站點中各種各樣的區(qū)域。在Web.sitemap中的每個< siteMapNode>元素描述了一個站點結(jié)構(gòu)中的一個區(qū)域。

asp.net通過DotNET 框架中的SiteMap類顯示站點地圖的結(jié)構(gòu)。這個類有一個CurrentNode屬性,它返回當(dāng)前用戶正在訪問的節(jié)點的信息;RootNode屬性返回站點地圖的根節(jié)點信息(在我們的站點地圖中是Home)。CurrentNode呵RootNode屬性都返回SiteMapNode實例,SiteMapNode包含ParentNode,ChildNodes,NextSibling,PreviousSibling等屬性。添加站點地圖后,這些屬性允許站點地圖的層次可以被遍歷。

【編輯推薦】

  1. ASP.NET MVC路徑選擇系統(tǒng)構(gòu)建
  2. ASP.NET MVC框架中的URL路徑選擇場景
  3. ASP.NET MVC 框架URL路徑選擇規(guī)則
  4. ASP.NET MVC框架:使用強類型類來傳遞ViewData
  5. 使用ASP.NET MVC框架創(chuàng)建電子商務(wù)網(wǎng)站

 

責(zé)任編輯:book05 來源: 博客園
相關(guān)推薦

2009-07-24 16:55:53

添加aspx頁面

2009-07-27 03:21:00

breadcrumb導(dǎo)

2009-07-27 09:28:55

TableAdapte

2009-07-27 08:51:24

ObjectDataS

2009-07-24 17:15:52

SiteMapData

2009-07-27 16:09:05

GridView顯示數(shù)

2009-07-24 13:08:52

DataRowASP.NET 2.0

2009-07-24 13:08:03

BLL類ASP.NET 2.0

2009-07-27 09:35:57

業(yè)務(wù)邏輯層

2009-07-24 14:23:16

定制編碼DAL

2009-07-27 09:01:44

ObjectDataS

2009-07-24 16:37:04

創(chuàng)建母版頁asp.net 2.0

2009-07-27 16:22:54

GridView選擇行

2009-07-24 12:41:21

BLL類

2009-07-24 13:25:43

創(chuàng)建數(shù)據(jù)訪問層

2010-06-25 08:51:46

ASP.NET MVC

2009-07-27 09:39:04

SelectMetho

2009-07-23 14:43:24

數(shù)據(jù)源控件ASP.NET 2.0

2009-07-24 14:15:51

數(shù)據(jù)訪問層

2009-07-22 17:21:27

ASP.NET 2.0
點贊
收藏

51CTO技術(shù)棧公眾號