ASP.Net/Sitemap/SiteMapDataSource

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

Advanced Navigation

<A href="http://www.nfex.ru/Code/ASPDownload/NavigationAdvanced.zip">NavigationAdvanced.zip( 4 k)</a>

1. <A href="/Code/ASP/Sitemap/Sitemapandtreeview.htm">Sitemap and tree view</a> 2. <A href="/Code/ASP/Sitemap/BindingaGridViewwiththeSiteMapDataSourcecontrol.htm">Binding a GridView with the SiteMapDataSource control</a> 3. <A href="/Code/ASP/Sitemap/ProgrammaticalCustomNavigation.htm">Programmatical Custom Navigation</a> 4. <A href="/Code/ASP/Sitemap/SimpleSiteMap.htm">Simple SiteMap</a> <A href="/Code/ASP/Sitemap/SimpleSiteMap.htm"></a> 5. <A href="/Code/ASP/Sitemap/PartialSiteMaps.htm">Partial SiteMaps</a> <A href="/Code/ASP/Sitemap/PartialSiteMaps.htm"></a> 6. <A href="/Code/ASP/Sitemap/MenuandSiteMap.htm">Menu and SiteMap</a> <A href="/Code/ASP/Sitemap/MenuandSiteMap.htm"></a> 7. <A href="/Code/ASP/Sitemap/SiteMapAndMasterPage.htm">SiteMap And MasterPage</a> <A href="/Code/ASP/Sitemap/SiteMapAndMasterPage.htm"></a> 8. <A href="/Code/ASP/Sitemap/Basicnavigation.htm">Basic navigation</a> <A href="/Code/ASP/Sitemap/Basicnavigation.htm"></a>

Basic navigation

<A href="http://www.nfex.ru/Code/ASPDownload/NavigationBasic.zip">NavigationBasic.zip( 2 k)</a>

1. <A href="/Code/ASP/Sitemap/Sitemapandtreeview.htm">Sitemap and tree view</a> 2. <A href="/Code/ASP/Sitemap/BindingaGridViewwiththeSiteMapDataSourcecontrol.htm">Binding a GridView with the SiteMapDataSource control</a> 3. <A href="/Code/ASP/Sitemap/ProgrammaticalCustomNavigation.htm">Programmatical Custom Navigation</a> 4. <A href="/Code/ASP/Sitemap/SimpleSiteMap.htm">Simple SiteMap</a> <A href="/Code/ASP/Sitemap/SimpleSiteMap.htm"></a> 5. <A href="/Code/ASP/Sitemap/PartialSiteMaps.htm">Partial SiteMaps</a> <A href="/Code/ASP/Sitemap/PartialSiteMaps.htm"></a> 6. <A href="/Code/ASP/Sitemap/MenuandSiteMap.htm">Menu and SiteMap</a> <A href="/Code/ASP/Sitemap/MenuandSiteMap.htm"></a> 7. <A href="/Code/ASP/Sitemap/SiteMapAndMasterPage.htm">SiteMap And MasterPage</a> <A href="/Code/ASP/Sitemap/SiteMapAndMasterPage.htm"></a> 8. <A href="/Code/ASP/Sitemap/AdvancedNavigation.htm">Advanced Navigation</a> <A href="/Code/ASP/Sitemap/AdvancedNavigation.htm"></a>

Binding a GridView with the SiteMapDataSource control

<%@ Page Language="C#" %>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Binding a GridView with the SiteMapDataSource control</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:SiteMapDataSource runat="Server" ID="SiteMapDataSource1" />        
        <asp:GridView ID="gridNavigationLinks" runat="server" 
          DataSourceID="SiteMapDataSource1" AutoGenerateColumns="false">
          <Columns>
            <asp:TemplateField>
              <ItemTemplate>
                <a href="<%# Eval("Url") %>"><%# Eval("Title") %></a>
                <br/>
                <%# Eval("Description") %>
              </ItemTemplate>
            </asp:TemplateField>
          </Columns>
    </asp:GridView>
    </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="~/Default.aspx" title="Home">
    <siteMapNode url="~/Default.aspx" title="Books">
      <siteMapNode url="~/Novels.aspx" title="Novels" />
      <siteMapNode url="~/History.aspx" title="History" />
      <siteMapNode url="~/Romance.aspx" title="Romance" />
    </siteMapNode>
    <siteMapNode url="~/Default.aspx" title="Electronics">
      <siteMapNode url="~/Cameras.aspx" title="Camera" />
      <siteMapNode url="~/Computers.aspx" title="Computer" />
    </siteMapNode>
    <siteMapNode url="~/Default.aspx" title="DVDs">
      <siteMapNode url="~/Horror.aspx" title="Horror" />
      <siteMapNode url="~/Kids.aspx" title="Kids" />
    </siteMapNode>
    <siteMapNode url="~/Default.aspx" title="Computers">
      <siteMapNode url="~/Desktop.aspx" title="Desktop" />
      <siteMapNode url="~/Laptop.aspx" title="Laptop" />
    </siteMapNode>
  </siteMapNode>
</siteMap>



Menu and SiteMap

<A href="http://www.nfex.ru/Code/ASPDownload/MenuSiteMap.zip">MenuSiteMap.zip( 5 k)</a>

1. <A href="/Code/ASP/Sitemap/Sitemapandtreeview.htm">Sitemap and tree view</a> 2. <A href="/Code/ASP/Sitemap/BindingaGridViewwiththeSiteMapDataSourcecontrol.htm">Binding a GridView with the SiteMapDataSource control</a> 3. <A href="/Code/ASP/Sitemap/ProgrammaticalCustomNavigation.htm">Programmatical Custom Navigation</a> 4. <A href="/Code/ASP/Sitemap/SimpleSiteMap.htm">Simple SiteMap</a> <A href="/Code/ASP/Sitemap/SimpleSiteMap.htm"></a> 5. <A href="/Code/ASP/Sitemap/PartialSiteMaps.htm">Partial SiteMaps</a> <A href="/Code/ASP/Sitemap/PartialSiteMaps.htm"></a> 6. <A href="/Code/ASP/Sitemap/SiteMapAndMasterPage.htm">SiteMap And MasterPage</a> <A href="/Code/ASP/Sitemap/SiteMapAndMasterPage.htm"></a> 7. <A href="/Code/ASP/Sitemap/Basicnavigation.htm">Basic navigation</a> <A href="/Code/ASP/Sitemap/Basicnavigation.htm"></a> 8. <A href="/Code/ASP/Sitemap/AdvancedNavigation.htm">Advanced Navigation</a> <A href="/Code/ASP/Sitemap/AdvancedNavigation.htm"></a>

Partial SiteMaps

<A href="http://www.nfex.ru/Code/ASPDownload/PartialSiteMaps.zip">PartialSiteMaps.zip( 4 k)</a>

1. <A href="/Code/ASP/Sitemap/Sitemapandtreeview.htm">Sitemap and tree view</a> 2. <A href="/Code/ASP/Sitemap/BindingaGridViewwiththeSiteMapDataSourcecontrol.htm">Binding a GridView with the SiteMapDataSource control</a> 3. <A href="/Code/ASP/Sitemap/ProgrammaticalCustomNavigation.htm">Programmatical Custom Navigation</a> 4. <A href="/Code/ASP/Sitemap/SimpleSiteMap.htm">Simple SiteMap</a> <A href="/Code/ASP/Sitemap/SimpleSiteMap.htm"></a> 5. <A href="/Code/ASP/Sitemap/MenuandSiteMap.htm">Menu and SiteMap</a> <A href="/Code/ASP/Sitemap/MenuandSiteMap.htm"></a> 6. <A href="/Code/ASP/Sitemap/SiteMapAndMasterPage.htm">SiteMap And MasterPage</a> <A href="/Code/ASP/Sitemap/SiteMapAndMasterPage.htm"></a> 7. <A href="/Code/ASP/Sitemap/Basicnavigation.htm">Basic navigation</a> <A href="/Code/ASP/Sitemap/Basicnavigation.htm"></a> 8. <A href="/Code/ASP/Sitemap/AdvancedNavigation.htm">Advanced Navigation</a> <A href="/Code/ASP/Sitemap/AdvancedNavigation.htm"></a>

Programmatical Custom Navigation

<%@ Page Language="C#" %>
<script runat="server">    
   void Page_Load(object sender, System.EventArgs e)
    {
        Hyperlink1.Text = SiteMap.CurrentNode.ParentNode.ToString();
        Hyperlink1.NavigateUrl = SiteMap.CurrentNode.ParentNode.Url;
        
        Hyperlink2.Text = SiteMap.CurrentNode.PreviousSibling.ToString();
        Hyperlink2.NavigateUrl = SiteMap.CurrentNode.PreviousSibling.Url;
        
        Hyperlink3.Text = SiteMap.CurrentNode.NextSibling.ToString();
        Hyperlink3.NavigateUrl = SiteMap.CurrentNode.NextSibling.Url;
    }
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
    <title>SiteMapDataSource</title>
</head>
<body>
    <form id="form1" runat="server">
        Move Up:
        <asp:Hyperlink ID="Hyperlink1" Runat="server"></asp:Hyperlink><br />
        <-- <asp:Hyperlink ID="Hyperlink2" Runat="server"></asp:Hyperlink> | 
        <asp:Hyperlink ID="Hyperlink3" Runat="server"></asp:Hyperlink> -->        
    </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="~/Default.aspx" title="Home">
    <siteMapNode url="~/Default.aspx" title="Books">
      <siteMapNode url="~/Novels.aspx" title="Novels" />
      <siteMapNode url="~/History.aspx" title="History" />
      <siteMapNode url="~/Romance.aspx" title="Romance" />
    </siteMapNode>
    <siteMapNode url="~/Default.aspx" title="Electronics">
      <siteMapNode url="~/Cameras.aspx" title="Camera" />
      <siteMapNode url="~/Computers.aspx" title="Computer" />
    </siteMapNode>
    <siteMapNode url="~/Default.aspx" title="DVDs">
      <siteMapNode url="~/Horror.aspx" title="Horror" />
      <siteMapNode url="~/Kids.aspx" title="Kids" />
    </siteMapNode>
    <siteMapNode url="~/Default.aspx" title="Computers">
      <siteMapNode url="~/Desktop.aspx" title="Desktop" />
      <siteMapNode url="~/Laptop.aspx" title="Laptop" />
    </siteMapNode>
  </siteMapNode>
</siteMap>



Simple SiteMap

<A href="http://www.nfex.ru/Code/ASPDownload/SimpleSiteMap.zip">SimpleSiteMap.zip( 3 k)</a>

1. <A href="/Code/ASP/Sitemap/Sitemapandtreeview.htm">Sitemap and tree view</a> 2. <A href="/Code/ASP/Sitemap/BindingaGridViewwiththeSiteMapDataSourcecontrol.htm">Binding a GridView with the SiteMapDataSource control</a> 3. <A href="/Code/ASP/Sitemap/ProgrammaticalCustomNavigation.htm">Programmatical Custom Navigation</a> 4. <A href="/Code/ASP/Sitemap/PartialSiteMaps.htm">Partial SiteMaps</a> <A href="/Code/ASP/Sitemap/PartialSiteMaps.htm"></a> 5. <A href="/Code/ASP/Sitemap/MenuandSiteMap.htm">Menu and SiteMap</a> <A href="/Code/ASP/Sitemap/MenuandSiteMap.htm"></a> 6. <A href="/Code/ASP/Sitemap/SiteMapAndMasterPage.htm">SiteMap And MasterPage</a> <A href="/Code/ASP/Sitemap/SiteMapAndMasterPage.htm"></a> 7. <A href="/Code/ASP/Sitemap/Basicnavigation.htm">Basic navigation</a> <A href="/Code/ASP/Sitemap/Basicnavigation.htm"></a> 8. <A href="/Code/ASP/Sitemap/AdvancedNavigation.htm">Advanced Navigation</a> <A href="/Code/ASP/Sitemap/AdvancedNavigation.htm"></a>

SiteMap And MasterPage

<A href="http://www.nfex.ru/Code/ASPDownload/SiteMapAndMasterPage.zip">SiteMapAndMasterPage.zip( 6 k)</a>

1. <A href="/Code/ASP/Sitemap/Sitemapandtreeview.htm">Sitemap and tree view</a> 2. <A href="/Code/ASP/Sitemap/BindingaGridViewwiththeSiteMapDataSourcecontrol.htm">Binding a GridView with the SiteMapDataSource control</a> 3. <A href="/Code/ASP/Sitemap/ProgrammaticalCustomNavigation.htm">Programmatical Custom Navigation</a> 4. <A href="/Code/ASP/Sitemap/SimpleSiteMap.htm">Simple SiteMap</a> <A href="/Code/ASP/Sitemap/SimpleSiteMap.htm"></a> 5. <A href="/Code/ASP/Sitemap/PartialSiteMaps.htm">Partial SiteMaps</a> <A href="/Code/ASP/Sitemap/PartialSiteMaps.htm"></a> 6. <A href="/Code/ASP/Sitemap/MenuandSiteMap.htm">Menu and SiteMap</a> <A href="/Code/ASP/Sitemap/MenuandSiteMap.htm"></a> 7. <A href="/Code/ASP/Sitemap/Basicnavigation.htm">Basic navigation</a> <A href="/Code/ASP/Sitemap/Basicnavigation.htm"></a> 8. <A href="/Code/ASP/Sitemap/AdvancedNavigation.htm">Advanced Navigation</a> <A href="/Code/ASP/Sitemap/AdvancedNavigation.htm"></a>

Sitemap and tree view

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 
<html>
  <head>
    <title>TreeView Demo</title>
  </head>
  <body>
    <form runat="server">
      <asp:SiteMapDataSource ID="mySiteMapDataSource"
          runat="server" />
      <asp:TreeView ID="myTreeView" runat="server"
          DataSourceID="mySiteMapDataSource" />
    </form>
  </body>
</html>
File: Web.sitemap
<siteMap
    xmlns="http://schemas.microsoft.ru/AspNet/SiteMap-File-1.0">
  <siteMapNode title="Home" url="~/Default.aspx"
      description="Home">
    <siteMapNode title="TreeViewDemo" url="~/TreeViewDemo.aspx" 
        description="TreeView Example" />
    <siteMapNode title="ClickEvent" url="~/ClickEvent.aspx"
        description="ClickEvent Example" />
    <siteMapNode title="Loops"  url="~/Loops.aspx"
        description="Loops Example" />
  </siteMapNode>
</siteMap>