在ASP.NET 2.0中使用頁面導航控制項

來源:互聯網
上載者:User
幾乎每個網站裡,為了方便使用者在網站中進行頁面導航,都少不了使用頁面導航控制項。有了頁面導航的功能,使用者可以很方便地在一個複雜的網站中進行頁面之間的跳轉。在以往的WEB編程中,要寫一個好的頁面導航功能,並不是那麼容易的,也要使用一些技巧。而在asp.net 2.0中,為了方便進行頁面導航,新增了一個叫做頁面導航控制項sitemapdatasource,其中還可以綁定到不同的其他頁面控制項,比如treeview,menu等,十分靈活,使到能很方便地實現頁面導航的不同形式,而且還提供了運行時的編程介面,可以以編程的形式動態實現頁面導航控制項。本文將簡單以幾個例子來介紹一下在asp.net 2.0中如何?頁面導航。
  頁面導航的結構和sitemapdatasource控制項
  在asp.net 2.0中,要實現頁面導航,應該先以xml的形式,提供出整個網站的頁面結構層次。我們可以編寫一個叫web.sitemap的XML文字檔,在該檔案中定義出整個要導航頁面的結構層次。舉例如下:
<?xml version="1.0" encoding="utf-8" ?>
<siteMap>
 <siteMapNode title="Default" description="Home" url="Default.aspx" >
  <siteMapNode title="Members" description="Members" url="Members.aspx">
   <siteMapNode title="My Account" description="My Account" url="MyAccount.aspx" />
   <siteMapNode title="Products" description="Products" url="Products.aspx" />
  </siteMapNode>
  <siteMapNode title="Administration" description="Administration" url="~/Admin/Default.aspx">
   <siteMapNode title="Customer" description="Customer Admin" url="~/Admin/Customer/default.aspx" />
   <siteMapNode title="Products Admin" description="Products Admin" url="~/Admin/ProductsAdmin.aspx" />
  </siteMapNode>
 </siteMapNode>
</siteMap>

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.