1.配置地图文件(数据源)
Web.sitemap:
<?xml version="1.0" encoding="utf-8" ?>
<siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0" >
<siteMapNode url="/" title="木子屋" description="">
<siteMapNode url="Default.aspx" title="首页" description="" />
<siteMapNode url="List1.aspx" title="分类一" description="">
<siteMapNode url="Article11.aspx" title="文章一" description="" />
<siteMapNode url="Article12.aspx" title="文章二" description="" />
</siteMapNode>
<siteMapNode url="List2.aspx" title="分类二" description="">
<siteMapNode url="Article21.aspx" title="文章一" description="" />
<siteMapNode url="Article22.aspx" title="文章二" description="" />
</siteMapNode>
<siteMapNode url="List3.aspx" title="分类三" description="">
<siteMapNode url="Article31.aspx" title="文章一" description="" />
<siteMapNode url="Article32.aspx" title="文章二" description="" />
</siteMapNode>
</siteMapNode>
</siteMap>web.config:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.web>
<!-- 站点地址设置 -->
<siteMap>
<providers>
<add siteMapFile="Web.sitemap" name="[color=Red]WebMap[/color]" type="System.Web.XmlSiteMapProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
</providers>
</siteMap>
<compilation debug="false" />
<authentication mode="Windows" />
</system.web>
</configuration>2.导航控件SiteMapPath、TreeView使用示例
①.SiteMapPath控件使用使用示例
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>SiteMapPath控件示例-Mzwu.Com</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:SiteMapPath ID="SiteMapPath1" runat="server" SiteMapProvider="[color=Red]WebMap[/color]">
</asp:SiteMapPath>
</div>
</form>
</body>
</html>②.TreeView控件使用示例
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>TreeView控件示例-Mzwu.Com</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:SiteMapDataSource ID="SiteMapDataSource1" runat="server"
SiteMapProvider="[color=Red]WebMap[/color]" />
<asp:TreeView ID="TreeView1" runat="server" DataSourceID="SiteMapDataSource1"
ExpandDepth="1" ShowLines="True">
</asp:TreeView>
</div>
</form>
</body>
</html>说明
·TreeView控件必须和SiteMapDataSource控件配合使用;
·若使用默认站点地图(Web.sitemap)做数据源,SiteMapPath和SiteMapDataSource控件的SiteMapProvider属性可省略,web.config中也就不需进行另外配置了;
评论(0)
暂无评论。