温故知新ASP.NET 2.0(C#)(3) - SiteMap(站点地图)
[1] 温故知新ASP.NET 2.0(C#)(3) - SiteMap(站点地图)
[2] 温故知新ASP.NET 2.0(C#)(3) - SiteMap(站点地图)
[3] 温故知新ASP.NET 2.0(C#)(3) - SiteMap(站点地图)
[4] 温故知新ASP.NET 2.0(C#)(3) - SiteMap(站点地图)
[2] 温故知新ASP.NET 2.0(C#)(3) - SiteMap(站点地图)
[3] 温故知新ASP.NET 2.0(C#)(3) - SiteMap(站点地图)
[4] 温故知新ASP.NET 2.0(C#)(3) - SiteMap(站点地图)
系列文章导航:
温故知新ASP.NET 2.0(C#)(1) - MasterPage(母版页)
温故知新ASP.NET 2.0(C#)(1) - MasterPage(母版页)
温故知新ASP.NET 2.0(C#)(2) - Themes(主题)
温故知新ASP.NET 2.0(C#)(3) - SiteMap(站点地图)
温故知新ASP.NET 2.0(C#)(4) - 缓存&SqlCacheDependency
温故知新ASP.NET 2.0(C#)(5) - Localization
温故知新ASP.NET 2.0(C#)(8) - DataSourceControl
温故知新ASP.NET 2.0(C#)(6) - Membership&RoleManager
温故知新ASP.NET 2.0(C#)(7) - Profile
温故知新ASP.NET 2.0(C#)(8) - DataSourceControl
SiteMap/Test.aspx.cs
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class SiteMap_Test : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
// 获取当前节点的Title
lbl.Text = "当前节点标题:" + SiteMap.CurrentNode.Title + "<br />";
// 取得url为“~/Default.aspx”的SiteMapNode
SiteMapNode smn = SiteMap.Provider.FindSiteMapNode("~/Default.aspx");
lbl.Text += "Default.aspx节点的Url:" + smn.Url;
}
}
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class SiteMap_Test : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
// 获取当前节点的Title
lbl.Text = "当前节点标题:" + SiteMap.CurrentNode.Title + "<br />";
// 取得url为“~/Default.aspx”的SiteMapNode
SiteMapNode smn = SiteMap.Provider.FindSiteMapNode("~/Default.aspx");
lbl.Text += "Default.aspx节点的Url:" + smn.Url;
}
}
站点地图测试(从数据库读数据)
SiteMap/FromDatabase.aspx
<%@ Page Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true" CodeFile="FromDatabase.aspx.cs"
Inherits="SiteMap_FromDatabase" Title="站点地图测试(从数据库读数据)" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
<asp:TreeView ID="TreeView1" runat="server" DataSourceID="SiteMapDataSource1">
</asp:TreeView>
<asp:SiteMapDataSource ID="SiteMapDataSource1" runat="server" SiteMapProvider="SqlSiteMapProvider" />
</asp:Content>
Inherits="SiteMap_FromDatabase" Title="站点地图测试(从数据库读数据)" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
<asp:TreeView ID="TreeView1" runat="server" DataSourceID="SiteMapDataSource1">
</asp:TreeView>
<asp:SiteMapDataSource ID="SiteMapDataSource1" runat="server" SiteMapProvider="SqlSiteMapProvider" />
</asp:Content>