ASP.Net/Sitemap/Web.sitemap — различия между версиями

Материал из .Net Framework эксперт
Перейти к: навигация, поиск
м (1 версия)
 
(нет различий)

Версия 15:30, 26 мая 2010

Adding style to the PathSeparator property

<%@ Page Language="C#" %>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
    <title>Using the SiteMapPath Server Control</title>
</head>
<body>
    <form id="form1" runat="server">
        <asp:SiteMapPath ID="Sitemappath1" Runat="server" PathSeparator=" | ">
           <PathSeparatorStyle Font-Bold="true" Font-Names="Verdana" ForeColor="#663333" 
            BackColor="#cccc66"></PathSeparatorStyle>
        </asp:SiteMapPath>
    </form>
</body>
</html>
File: Web.sitemap
<?xml version="1.0" encoding="utf-8" ?>
    
<siteMap xmlns="http://schemas.microsoft.ru/AspNet/SiteMap-File-1.0" >
   
   <siteMapNode title="Home" description="Home Page" url="Default.aspx">
      <siteMapNode title="News" description="The Latest News" url="News.aspx">
         <siteMapNode title="A" description="A News" url="News.aspx?cat=us" />
         <siteMapNode title="World" description="World News" url="News.aspx?cat=world" />
         <siteMapNode title="Technology" description="Technology News" url="News.aspx?cat=tech" />
         <siteMapNode title="Sports" description="Sports News" url="News.aspx?cat=sport" />
      </siteMapNode>
      <siteMapNode title="Weather" description="The Latest Weather" url="Weather.aspx" />
   </siteMapNode>
</siteMap>



An example of a Web.sitemap file

File: Web.sitemap
<?xml version="1.0" encoding="utf-8" ?>
    
<siteMap xmlns="http://schemas.microsoft.ru/AspNet/SiteMap-File-1.0" >
   
   <siteMapNode title="Home" description="Home Page" url="Default.aspx">
      <siteMapNode title="News" description="The Latest News" url="News.aspx">
         <siteMapNode title="A" description="A News" url="News.aspx?cat=us" />
         <siteMapNode title="World" description="World News" url="News.aspx?cat=world" />
         <siteMapNode title="Technology" description="Technology News" url="News.aspx?cat=tech" />
         <siteMapNode title="Sports" description="Sports News" url="News.aspx?cat=sport" />
      </siteMapNode>
      <siteMapNode title="Weather" description="The Latest Weather" url="Weather.aspx" />
   </siteMapNode>
</siteMap>



BulletedList SiteMapDataSource Consumer

<%@ Page Language="C#" AutoEventWireup="false" %>
<!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" xml:lang="en" >
<head runat="server">
    <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
</head>
<body>
   <form id="form1" runat="server">
   <div id="container">
      <h1>SiteMap Consumer</h1>
      <asp:BulletedList ID="bulHoriz" runat="Server"  
         DataValueField="url" DataTextField="title"
         DataSourceID="siteSource" DisplayMode="HyperLink" />
      <asp:BulletedList ID="bulVert" runat="Server" 
         DataValueField="url" DataTextField="title"
         DataSourceID="siteSource" DisplayMode="HyperLink" />
      <asp:SiteMapDataSource ID="siteSource" runat="server" 
         ShowStartingNode="false"  />
   </div>
   </form>
</body>
</html>
File: Web.sitemap
<?xml version="1.0" encoding="utf-8" ?>
<siteMap xmlns="http://schemas.microsoft.ru/AspNet/SiteMap-File-1.0" >
   <siteMapNode url="BookHome.aspx" title="Home"  
            description="Return to home page">
      <siteMapNode url="Catalog.aspx" title="Catalog" >
         <siteMapNode url="Categories.aspx" title="Categories" >
            <siteMapNode url="List.aspx?cat=1" title="Graphics" />
            <siteMapNode url="List.aspx?cat=2" title="Internet" />
            <siteMapNode url="List.aspx?cat=3" title="Networking" />
         </siteMapNode>
         <siteMapNode url="Series.aspx" title="Series" >
            <siteMapNode url="List.aspx?series=1" title="Core Series" />
            <siteMapNode url="List.aspx?series=2" title=".NET Series" />
            <siteMapNode url="List.aspx?series=3" title="Signature Series"/>
         </siteMapNode>
      </siteMapNode>
      <siteMapNode url="Search.aspx" title="Search"  />
      <siteMapNode url="Help.aspx" title="Help" >
         <siteMapNode url="About.aspx" title="About Us" />
         <siteMapNode url="Contact.aspx" title="Contact Us" />
      </siteMapNode>
   </siteMapNode>
</siteMap>



Changing the PathSeparator value

 
<%@ Page Language="C#" %>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
    <title>Using the SiteMapPath Server Control</title>
</head>
<body>
    <form id="form1" runat="server">
        <asp:SiteMapPath ID="Sitemappath1" Runat="server" PathSeparator=" | ">
        </asp:SiteMapPath>
    </form>
</body>
</html>

File: Web.sitemap
<?xml version="1.0" encoding="utf-8" ?>
    
<siteMap xmlns="http://schemas.microsoft.ru/AspNet/SiteMap-File-1.0" >
   
   <siteMapNode title="Home" description="Home Page" url="Default.aspx">
      <siteMapNode title="News" description="The Latest News" url="News.aspx">
         <siteMapNode title="A" description="A News" url="News.aspx?cat=us" />
         <siteMapNode title="World" description="World News" url="News.aspx?cat=world" />
         <siteMapNode title="Technology" description="Technology News" url="News.aspx?cat=tech" />
         <siteMapNode title="Sports" description="Sports News" url="News.aspx?cat=sport" />
      </siteMapNode>
      <siteMapNode title="Weather" description="The Latest Weather" url="Weather.aspx" />
   </siteMapNode>
</siteMap>



Creating a basic .sitemap file for localization

 
<?xml version="1.0" encoding="utf-8" ?>
    
<siteMap xmlns="http://schemas.microsoft.ru/AspNet/SiteMap-File-1.0" 
  enableLocalization="true">
  <siteMapNode url="Default.aspx" resourceKey="Home">
         <siteMapNode url="News.aspx" resourceKey="News">
                <siteMapNode url="News.aspx?cat=us" resourceKey="NewsUS" />
                <siteMapNode url="News.aspx?cat=world" resourceKey="NewsWorld" />
                <siteMapNode url="News.aspx?cat=tech" resourceKey="NewsTech" />
                <siteMapNode url="News.aspx?cat=sport" resourceKey="NewsSport" />
         </siteMapNode>
  </siteMapNode>
</siteMap>



Display Levels

<%@ Page Language="C#" %>
<!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 id="Head1" runat="server">
    <title>Adjusting the Menu Display Levels</title>
</head>
<body>
   <form id="form1" runat="server">
   <div id="container">
      <asp:Menu id="menuPrimary" 
                runat="server" 
                DataSourceID="siteSource" 
                Orientation="Horizontal" 
                StaticDisplayLevels="1" 
                MaximumDynamicDisplayLevels="0">
      </asp:Menu>
      <asp:Menu id="menuSecondary" 
                runat="server" 
                DataSourceID="siteSource"  
                Orientation="Vertical"
                StaticDisplayLevels="3" 
                MaximumDynamicDisplayLevels="2" >
      </asp:Menu>
      <asp:SiteMapDataSource ID="siteSource" 
                             runat="server" 
                             ShowStartingNode="false"  />
   </div>
   </form>
</body>
</html>
File: Web.sitemap
<?xml version="1.0" encoding="utf-8" ?>
<siteMap xmlns="http://schemas.microsoft.ru/AspNet/SiteMap-File-1.0" >
   <siteMapNode url="BookHome.aspx" title="Home"  
            description="Return to home page">
      <siteMapNode url="Catalog.aspx" title="Catalog" >
         <siteMapNode url="Categories.aspx" title="Categories" >
            <siteMapNode url="List.aspx?cat=1" title="Graphics" />
            <siteMapNode url="List.aspx?cat=2" title="Internet" />
            <siteMapNode url="List.aspx?cat=3" title="Networking" />
         </siteMapNode>
         <siteMapNode url="Series.aspx" title="Series" >
            <siteMapNode url="List.aspx?series=1" title="Core Series" />
            <siteMapNode url="List.aspx?series=2" title=".NET Series" />
            <siteMapNode url="List.aspx?series=3" title="Signature Series"/>
         </siteMapNode>
      </siteMapNode>
      <siteMapNode url="Search.aspx" title="Search"  />
      <siteMapNode url="Help.aspx" title="Help" >
         <siteMapNode url="About.aspx" title="About Us" />
         <siteMapNode url="Contact.aspx" title="Contact Us" />
      </siteMapNode>
   </siteMapNode>
</siteMap>



Set the dispay levels in a Menu control

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="TemplatedMenu2" %>
<!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" xml:lang="en">
<head id="Head1" runat="server">
</head>
<body>
   <form id="form1" runat="server">
   <div id="container">
      <asp:Menu id="menuPrimary" 
                runat="server" 
                DataSourceID="siteSource" 
                Orientation="Horizontal" 
                StaticDisplayLevels="1"  
                StaticEnableDefaultPopOutImage="false"
                MaximumDynamicDisplayLevels="1">
         <StaticItemTemplate>
            <asp:button ID="btnItem" runat="server" 
               Text="<%# Eval("Text") %>" 
               PostBackUrl="<%# Eval("NavigateUrl") %>"
               Width="150" />
         </StaticItemTemplate>
         <DynamicMenuStyle CssClass="dynamicMenu"/> 
         <DynamicItemTemplate>
            <asp:hyperlink ID="imgbtnItem" runat="server" 
               NavigateUrl="<%# Eval("NavigateUrl") %>"
               ToolTip="<%# Eval("Text") %>" />
            <asp:hyperlink ID="lnkItem" runat="server" 
               Text="<%# Eval("Text") %>" 
               NavigateUrl="<%# Eval("NavigateUrl") %>" />
         </DynamicItemTemplate>
      </asp:Menu>        
      <asp:SiteMapDataSource ID="siteSource" 
                             runat="server" 
                             ShowStartingNode="false"  
                             StartingNodeUrl="Catalog.aspx"/>
   </div>
   </form>
</body>
</html>
File: Default.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 TemplatedMenu2 : System.Web.UI.Page
{
   protected void btnItem_Command(object sender, CommandEventArgs e)
   {
      string url = e.rumandName;
      Response.Redirect(url);
   }
}
File: Web.sitemap
<?xml version="1.0" encoding="utf-8" ?>
<siteMap xmlns="http://schemas.microsoft.ru/AspNet/SiteMap-File-1.0" >
   <siteMapNode url="BookHome.aspx" title="Home"  
            description="Return to home page">
      <siteMapNode url="Catalog.aspx" title="Catalog" >
         <siteMapNode url="Categories.aspx" title="Categories" >
            <siteMapNode url="List.aspx?cat=1" title="Graphics" />
            <siteMapNode url="List.aspx?cat=2" title="Internet" />
            <siteMapNode url="List.aspx?cat=3" title="Networking" />
         </siteMapNode>
         <siteMapNode url="Series.aspx" title="Series" >
            <siteMapNode url="List.aspx?series=1" title="Core Series" />
            <siteMapNode url="List.aspx?series=2" title=".NET Series" />
            <siteMapNode url="List.aspx?series=3" title="Signature Series"/>
         </siteMapNode>
      </siteMapNode>
      <siteMapNode url="Search.aspx" title="Search"  />
      <siteMapNode url="Help.aspx" title="Help" >
         <siteMapNode url="About.aspx" title="About Us" />
         <siteMapNode url="Contact.aspx" title="Contact Us" />
      </siteMapNode>
   </siteMapNode>
</siteMap>



SiteMapNode

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="CatalogB" %>
<!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 id="Head1" runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
       <asp:BulletedList ID="bulPrimary" runat="Server"  
         DataValueField="url" DataTextField="title" CssClass="bulHoriz"
         DataSourceID="primarySiteSource" DisplayMode="HyperLink"  />
         
      <asp:SiteMapDataSource ID="primarySiteSource" runat="server" 
         ShowStartingNode="false" />
         
      <div id="nodes">
        <asp:HyperLink ID="lnkHome" runat="server" Text="Home" />
        <asp:HyperLink ID="lnkPrev" runat="server"  />
        <asp:HyperLink ID="lnkNext" runat="server"  />
        <asp:HyperLink ID="lnkUp" runat="server"  />
      </div>
      
    </div>
    </form>
</body>
</html>
</html>

File: Default.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 CatalogB : System.Web.UI.Page
{
   protected void Page_Load(object sender, EventArgs e)
   {
      SiteMapNode current = SiteMap.CurrentNode;
      SiteMapNode root = SiteMap.RootNode;
      foreach (SiteMapNode node in root.ChildNodes)
      {
         string s = node.Title;
      }
      SiteMapNode parent = current.ParentNode;
      if (parent != null)
      {
         foreach (SiteMapNode nodeA in parent.ChildNodes)
         {
            string s = nodeA.Title;
         }
      }
      if (SiteMap.CurrentNode != null)
      {
         lnkHome.NavigateUrl = SiteMap.RootNode.Url;
         if (SiteMap.CurrentNode.PreviousSibling != null)
         {
            lnkPrev.NavigateUrl = SiteMap.CurrentNode.PreviousSibling.Url;
            lnkPrev.Text = "Previous (" + SiteMap.CurrentNode.PreviousSibling.Title + ")";
         }
         else
            lnkPrev.Visible = false;
         if (SiteMap.CurrentNode.NextSibling != null)
         {
            lnkNext.NavigateUrl = SiteMap.CurrentNode.NextSibling.Url;
            lnkNext.Text = "Next (" + SiteMap.CurrentNode.NextSibling.Title + ")";
         }
         else
            lnkNext.Visible = false;
         if (SiteMap.CurrentNode.ParentNode != null)
         {
            lnkUp.NavigateUrl = SiteMap.CurrentNode.ParentNode.Url;
            lnkUp.Text = "Up (" + SiteMap.CurrentNode.ParentNode.Title + ")";
         }
         else
            lnkUp.Visible = false;
      }
   }
}
File: Web.sitemap
<?xml version="1.0" encoding="utf-8" ?>
<siteMap xmlns="http://schemas.microsoft.ru/AspNet/SiteMap-File-1.0" >
   <siteMapNode url="BookHome.aspx" title="Home"  
            description="Return to home page">
      <siteMapNode url="Catalog.aspx" title="Catalog" >
         <siteMapNode url="Categories.aspx" title="Categories" >
            <siteMapNode url="List.aspx?cat=1" title="Graphics" />
            <siteMapNode url="List.aspx?cat=2" title="Internet" />
            <siteMapNode url="List.aspx?cat=3" title="Networking" />
         </siteMapNode>
         <siteMapNode url="Series.aspx" title="Series" >
            <siteMapNode url="List.aspx?series=1" title="Core Series" />
            <siteMapNode url="List.aspx?series=2" title=".NET Series" />
            <siteMapNode url="List.aspx?series=3" title="Signature Series"/>
         </siteMapNode>
      </siteMapNode>
      <siteMapNode url="Search.aspx" title="Search"  />
      <siteMapNode url="Help.aspx" title="Help" >
         <siteMapNode url="About.aspx" title="About Us" />
         <siteMapNode url="Contact.aspx" title="Contact Us" />
      </siteMapNode>
   </siteMapNode>
</siteMap>



TreeView ImageSets

<%@ Page Language="C#"%>
<!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 ImageSets</title>
</head>
<body>
    <form id="form1" runat="server">
   <div id="container">
      <table>
         <tr>
            <td>
            <h2>Arrows</h2> 
            <asp:TreeView ID="tree1" runat="server" CssClass="tree" DataSourceID="siteSource" ImageSet="Arrows" />
            </td>
            <td>
            <h2>BulletedList</h2>
            <asp:TreeView ID="tree2" runat="server" CssClass="tree" DataSourceID="siteSource" ImageSet="BulletedList" />
            </td>  
            <td>
            <h2>Contacts</h2>
            <asp:TreeView ID="TreeView7" runat="server" CssClass="tree" DataSourceID="siteSource" ImageSet="Contacts" />
            </td>              
            <td>
            <h2>Custom</h2>
            <asp:TreeView ID="tree3" runat="server" CssClass="tree" DataSourceID="siteSource" ImageSet="Custom" />
            </td>                                
         </tr>
         <tr>
            <td>
            <h2>Events</h2> 
            <asp:TreeView ID="tree4" runat="server" CssClass="tree" DataSourceID="siteSource" ImageSet="Events" />
            </td>          
            <td>
            <h2>Faq</h2> 
            <asp:TreeView ID="TreeView2" runat="server" CssClass="tree" DataSourceID="siteSource" ImageSet="Faq" />
            </td>  
            <td>
            <h2>Inbox</h2>
            <asp:TreeView ID="TreeView3" runat="server" CssClass="tree" DataSourceID="siteSource" ImageSet="Inbox" />
            </td>   
            <td>
            <h2>Msdn</h2>
            <asp:TreeView ID="TreeView4" runat="server" CssClass="tree" DataSourceID="siteSource" ImageSet="Msdn" />
            </td>                                                      
         </tr>   
         <tr>
            <td>
            <h2>Simple</h2> 
            <asp:TreeView ID="TreeView5" runat="server" CssClass="tree" DataSourceID="siteSource" ImageSet="Simple" />
            </td> 
            <td>
            <h2>Simple2</h2> 
            <asp:TreeView ID="TreeView8" runat="server" CssClass="tree" DataSourceID="siteSource" ImageSet="Simple2" />
            </td>                      
            <td>
            <h2>WindowsHelp</h2> 
            <asp:TreeView ID="TreeView6" runat="server" CssClass="tree" DataSourceID="siteSource" ImageSet="WindowsHelp" />
            </td>   
            <td>
            <h2>XPFileExplorer</h2>
            <asp:TreeView ID="TreeView1" runat="server" CssClass="tree" DataSourceID="siteSource" ImageSet="XPFileExplorer" />
            </td>                                                     
         </tr>                 
      </table>
      <asp:SiteMapDataSource ID="siteSource" runat="server" 
         ShowStartingNode="true"  />
   </div>
    </form>
</body>
</html>
File: Web.sitemap
<?xml version="1.0" encoding="utf-8" ?>
<siteMap xmlns="http://schemas.microsoft.ru/AspNet/SiteMap-File-1.0" >
   <siteMapNode url="BookHome.aspx" title="Home"  
            description="Return to home page">
      <siteMapNode url="Catalog.aspx" title="Catalog" >
         <siteMapNode url="Categories.aspx" title="Categories" >
            <siteMapNode url="List.aspx?cat=1" title="Graphics" />
            <siteMapNode url="List.aspx?cat=2" title="Internet" />
            <siteMapNode url="List.aspx?cat=3" title="Networking" />
         </siteMapNode>
         <siteMapNode url="Series.aspx" title="Series" >
            <siteMapNode url="List.aspx?series=1" title="Core Series" />
            <siteMapNode url="List.aspx?series=2" title=".NET Series" />
            <siteMapNode url="List.aspx?series=3" title="Signature Series"/>
         </siteMapNode>
      </siteMapNode>
      <siteMapNode url="Search.aspx" title="Search"  />
      <siteMapNode url="Help.aspx" title="Help" >
         <siteMapNode url="About.aspx" title="About Us" />
         <siteMapNode url="Contact.aspx" title="Contact Us" />
      </siteMapNode>
   </siteMapNode>
</siteMap>



Use different site maps as well as the ability to choose a site map

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="ChooseSiteMap" %>
<!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>Choosing Site Map</title>
</head>
<body>
   <form id="form1" runat="server">
   <div id="container">
      <h1>Choosing SiteMap</h1>
      <asp:DropDownList ID="drpProviders" runat="server" AutoPostBack="True" OnSelectedIndexChanged="drpProviders_SelectedIndexChanged" />
      <asp:BulletedList ID="bulVert" runat="Server" 
         DataValueField="url" DataTextField="title"
         DataSourceID="siteSource" DisplayMode="HyperLink" />
      <asp:SiteMapDataSource ID="siteSource" runat="server" 
         ShowStartingNode="false"   />
   </div>
   </form>
</body>
</html>
File: Default.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 ChooseSiteMap : System.Web.UI.Page
{
   protected void Page_Load(object sender, EventArgs e)
   {
      if (!IsPostBack)
      {
         bulVert.Visible = false;
         foreach (SiteMapProvider provider in SiteMap.Providers)
         {
            drpProviders.Items.Add(new ListItem(provider.Name));
         }
      }
   }
   protected void drpProviders_SelectedIndexChanged(object sender, EventArgs e)
   {
      siteSource.SiteMapProvider = drpProviders.SelectedItem.Text;
      bulVert.Visible = true;
   }
}



Using an image as the separator

<%@ Page Language="C#" %>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
    <title>Using the SiteMapPath Server Control</title>
</head>
<body>
    <form id="form1" runat="server">
        <asp:SiteMapPath ID="SiteMapPath1" Runat="server">
            <PathSeparatorTemplate>
                <asp:Image ID="Image1" Runat="server" ImageUrl="divider.gif" />
            </PathSeparatorTemplate>            
        </asp:SiteMapPath>
   </form>
</body>
</html>
File: Web.sitemap
<?xml version="1.0" encoding="utf-8" ?>
    
<siteMap xmlns="http://schemas.microsoft.ru/AspNet/SiteMap-File-1.0" >
   
   <siteMapNode title="Home" description="Home Page" url="Default.aspx">
      <siteMapNode title="News" description="The Latest News" url="News.aspx">
         <siteMapNode title="A" description="A News" url="News.aspx?cat=us" />
         <siteMapNode title="World" description="World News" url="News.aspx?cat=world" />
         <siteMapNode title="Technology" description="Technology News" url="News.aspx?cat=tech" />
         <siteMapNode title="Sports" description="Sports News" url="News.aspx?cat=sport" />
      </siteMapNode>
      <siteMapNode title="Weather" description="The Latest Weather" url="Weather.aspx" />
   </siteMapNode>
</siteMap>



Using the Web.sitemap file with a SiteMapPath server control

<%@ Page Language="C#" %>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
    <title>Using the SiteMapPath Server Control</title>
</head>
<body>
    <form id="form1" runat="server">
        <asp:SiteMapPath ID="Sitemappath1" Runat="server">
        </asp:SiteMapPath>
    </form>
</body>
</html>

File: Web.sitemap
<?xml version="1.0" encoding="utf-8" ?>
    
<siteMap xmlns="http://schemas.microsoft.ru/AspNet/SiteMap-File-1.0" >
   
   <siteMapNode title="Home" description="Home Page" url="Default.aspx">
      <siteMapNode title="News" description="The Latest News" url="News.aspx">
         <siteMapNode title="A" description="A News" url="News.aspx?cat=us" />
         <siteMapNode title="World" description="World News" url="News.aspx?cat=world" />
         <siteMapNode title="Technology" description="Technology News" url="News.aspx?cat=tech" />
         <siteMapNode title="Sports" description="Sports News" url="News.aspx?cat=sport" />
      </siteMapNode>
      <siteMapNode title="Weather" description="The Latest Weather" url="Weather.aspx" />
   </siteMapNode>
</siteMap>