[Asp.net]網站地圖SiteMap

來源:互聯網
上載者:User

標籤:des   style   class   blog   code   java   

引言

在項目中發現使用網站地圖的控制項,之前沒總結過這方面的東西,就寫了一個demo測試了一下,這裡記錄一下,算是總結吧。

Web.sitemap
 1 <?xml version="1.0" encoding="utf-8" ?> 2 <siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0" > 3   <siteMapNode url="Default.aspx" title="首頁"  description=""> 4     <!--網站地圖節點,類似樹形結構,父節點包括子節點,如下--> 5     <siteMapNode url="" title="組織圖"  description=""> 6       <siteMapNode url="DepartmentManager.aspx" title="部門管理"  description=""></siteMapNode> 7       <siteMapNode url="UserManager.aspx" title="使用者管理"  description=""></siteMapNode> 8     </siteMapNode> 9     <siteMapNode url="" title="統計資訊"  description="">10       <siteMapNode url="VistorStatistics.aspx" title="訪問統計"  description=""></siteMapNode>11       <siteMapNode url="UserInfoStatistics.aspx" title="使用者統計"  description=""></siteMapNode>12     </siteMapNode>13     <siteMapNode url="" title="系統參數"  description="">14       <siteMapNode url="SystemManage.aspx" title="系統設定"  description=""></siteMapNode>15     </siteMapNode>16   </siteMapNode>17 </siteMap>
主版頁面
 1 <%@ Master Language="C#" AutoEventWireup="true" CodeBehind="Home.master.cs" Inherits="Wolfy.SiteMapDemo.Home" %> 2  3 <!DOCTYPE html> 4  5 <html xmlns="http://www.w3.org/1999/xhtml"> 6 <head runat="server"> 7     <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 8     <title></title> 9     <asp:ContentPlaceHolder ID="head" runat="server">10     </asp:ContentPlaceHolder>11 </head>12 <body>13     <form id="form1" runat="server">14         <div>15          16             <asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">17             </asp:ContentPlaceHolder>18             <asp:TreeView ID="TreeView1" runat="server"></asp:TreeView>19             <asp:SiteMapPath ID="SiteMapPath1" runat="server"></asp:SiteMapPath>20            21         </div>22     </form>23 </body>24 </html>

為treeview綁定資料來源

建立資料來源

 產生的html代碼:

1  <asp:TreeView ID="TreeView1" runat="server" DataSourceID="SiteMapDataSource1"></asp:TreeView>2             <asp:SiteMapDataSource ID="SiteMapDataSource1" runat="server" />3             <asp:SiteMapPath ID="SiteMapPath1" runat="server"></asp:SiteMapPath>
瀏覽結果

總結

東西非常簡單,也算是個知識點把,記錄一下。寧錯殺一千,不放過一個!

代碼:連結:http://pan.baidu.com/s/1jGsoYii 密碼:z88m

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.