📄 aspnet_navigation.asp@output=print
字号:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang="en-US" xml:lang="en-US" xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>ASP.NET 2.0 Navigation</title>
<link rel="shortcut icon" href="../favicon.ico" type="image/x-icon" />
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<meta name="Keywords" content="xml,tutorial,html,dhtml,css,xsl,xhtml,javascript,asp,ado,vbscript,dom,sql,colors,soap,php,authoring,programming,training,learning,beginner's guide,primer,lessons,school,howto,reference,examples,samples,source code,tags,demos,tips,links,FAQ,tag list,forms,frames,color table,w3c,cascading style sheets,active server pages,dynamic html,internet,database,development,Web building,Webmaster,html guide" />
<meta name="Description" content="Free HTML XHTML CSS JavaScript DHTML XML DOM XSL XSLT RSS AJAX ASP ADO PHP SQL tutorials, references, examples for web building." />
<meta http-equiv="pragma" content="no-cache" />
<meta http-equiv="cache-control" content="no-cache" />
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "../../https@ssl./default.htm" : "../../www./default.htm");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
var pageTracker = _gat._getTracker("UA-3855518-1");
pageTracker._initData();
pageTracker._trackPageview();
</script>
</head>
<body>
<p>From <b>http://www.w3schools.com</b> (Copyright Refsnes Data)</p>
<h1>ASP.NET 2.0 - Navigation</h1>
<a href="aspnet_masterpages.asp"><img alt="previous" border="0" src="../images/btn_previous.gif" /></a>
<a href="aspnet_refhtmlcontrols.asp"><img alt="next" border="0" src="../images/btn_next.gif" /></a>
<hr />
<p class="intro">ASP.NET 2.0 has built-in navigation controls</p>
<hr />
<h2>Web Site Navigation</h2>
<p>Maintaining the menu of a large web site is difficult and time consuming.</p>
<p>In ASP.NET 2.0 the menu can be stored in a file to make it easier
to maintain. This file is normally called <b>web.sitemap</b>, and is stored in
the root directory of the web.</p>
<p>In addition, ASP.NET 2.0 has three new navigation controls:</p>
<ul>
<li>Dynamic menus</li>
<li>TreeViews</li>
<li>Site Map Path</li>
</ul>
<hr />
<h2>The Sitemap File</h2>
<p>The following sitemap file is used in
this tutorial:</p>
<table border="1" width="100%" class="ex" cellspacing="0" id="table3">
<tr><td>
<pre><?xml version="1.0" encoding="ISO-8859-1" ?>
<siteMap>
<siteMapNode title="Home" url="/aspnet/w3home.aspx">
<siteMapNode title="Services" url="/aspnet/w3services.aspx">
<siteMapNode title="Training" url="/aspnet/w3training.aspx"/>
<siteMapNode title="Support" url="/aspnet/w3support.aspx"/>
</siteMapNode>
</siteMapNode>
</siteMap></pre>
</td></tr>
</table>
<p>Rules for creating a sitemap file:</p>
<ul>
<li>The XML file must contain a <siteMap> tag surrounding the content</li>
<li>The <siteMap> tag can only have one <siteMapNode> child node
(the "home" page)</li>
<li>Each <siteMapNode> can have several child nodes (web pages)</li>
<li>Each <siteMapNode> has attributes defining page title and
URL</li>
</ul>
<p><img border="0" src="../images/lamp.gif" width="15" height="15" alt="lamp" />
<b>Note:</b> The sitemap file must be placed in the root directory of the web and the
URL attributes must be relative to the root directory.</p>
<hr />
<h2>Dynamic Menu</h2>
<p>The <asp:Menu> control displays a standard site
navigation menu. </p>
<p><b>Code Example:</b></p>
<table border="1" width="100%" class="ex" cellspacing="0" id="table8">
<tr><td>
<pre><asp:SiteMapDataSource id="nav1" runat="server" /></pre>
<pre><form runat="server">
<asp:Menu runat="server" DataSourceId="nav1" />
</form></pre>
</td></tr>
</table>
<p>The <b><asp:Menu></b> control in the example above is a placeholder for a
server created navigation menu.</p>
<p>The data source of the control is defined by the <b>DataSourceId</b> attribute.
The <b>id="nav1"</b> connects it to the <b><asp:SiteMapDataSource></b> control.</p>
<p>The <b><asp:SiteMapDataSource></b> control automatically connects to
the default sitemap file (<b>web.sitemap</b>).</p>
<p><a target="_blank" href="w3services.aspx">Click here to see a demo of Menu,
TreeView, and SiteMapPath</a></p>
<hr />
<h2>TreeView</h2>
<p>The <asp:TreeView> control displays a multi level navigation menu.</p>
<p>The menu looks like a tree with branches that can be opened or closed with +
or - symbol. </p>
<p><b>Code Example:</b></p>
<table border="1" width="100%" class="ex" cellspacing="0" id="table6">
<tr><td>
<pre><asp:SiteMapDataSource id="nav1" runat="server" /></pre>
<pre><form runat="server">
<asp:TreeView runat="server" DataSourceId="nav1" />
</form></pre>
</td></tr>
</table>
<p>The <b><asp:TreeView></b> control in the example above is a placeholder for a
server created navigation menu.</p>
<p>The data source of the control is defined by the <b>DataSourceId</b> attribute.
The <b>id="nav1"</b> connects it to the <b><asp:SiteMapDataSource></b> control.</p>
<p>The <b><asp:SiteMapDataSource></b> control automatically connects to
the default sitemap file (<b>web.sitemap</b>).</p>
<p><a target="_blank" href="w3services.aspx">Click here to see a demo of Menu,
TreeView, and SiteMapPath</a></p>
<hr />
<h2>SiteMapPath</h2>
<p>The SiteMapPath control displays the trail (navigation path) to the current
page. The path acts as clickable links to previous pages.</p>
<p>Unlike the TreeView and Menu control the SiteMapPath control does <b>NOT</b> use
a SiteMapDataSource. The SiteMapPath control uses the web.sitemap file by default.</p>
<p><img border="0" src="../images/lamp.gif" width="15" height="15" alt="lamp" />
Tips: If the SiteMapPath displays incorrectly, most likely there is an URL error
(typo) in the web.sitemap file.</p>
<p><b>Code Example:</b></p>
<table border="1" width="100%" class="ex" cellspacing="0" id="table7">
<tr><td>
<pre><form runat="server">
<asp:SiteMapPath runat="server" />
</form></pre>
</td></tr>
</table>
<p>The <b><asp:SiteMapPath></b> control in the example above is a placeholder for a
server created site path display.</p>
<p><a target="_blank" href="w3services.aspx">Click here to see a demo of Menu,
TreeView, and SiteMapPath</a></p>
<hr />
<a href="aspnet_masterpages.asp"><img alt="previous" border="0" src="../images/btn_previous.gif" /></a>
<a href="aspnet_refhtmlcontrols.asp"><img alt="next" border="0" src="../images/btn_next.gif" width="100" height="20" /></a>
<p>From <b>http://www.w3schools.com</b> (Copyright Refsnes Data)</p>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -