WEB DEVELOPER SITE
HTMLCSSJAVASCRIPTSQLPHPBOOTSTRAPJQUERYANGULARXML
 

ASP.NET Web Forms - Navigation


ASP.NET has worked in route controls


Web Site Navigation

Maintaining the menu of a vast site is troublesome and time consuming.

In ASP.NET the menu can be put away in a record to make it less demanding to keep up. This record is typically called web.sitemap, and is put away in the root index of the web.

In expansion, ASP.NET has three new route controls:

  • Dynamic menus
  • TreeViews
  • Site Map Path

The Sitemap File

The following sitemap document is utilized in this tutorial:

<?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>

Rules for making a sitemap file:

  • The XML document must contain a <siteMap> tag encompassing the content
  • The <siteMap> tag can just have one <siteMapNode> youngster hub (the "home" page)
  • Each <siteMapNode> can have a few tyke hubs (web pages)
  • Each <siteMapNode> has qualities characterizing page title and URL

Dynamic Menu

The <asp:Menu> control shows a standard site route menu.

Code Example:

<asp:SiteMapDataSource id="nav1" runat="server"/>

<form runat="server">
<asp:Menu runat="server" DataSourceId="nav1"/>
</form>

The <asp:Menu> control in the precedent above is a placeholder for a server made route menu.

The information wellspring of the control is characterized by the DataSourceId characteristic. The id="nav1" interfaces it to the  <asp:SiteMapDataSource> control.

The <asp:SiteMapDataSource> control naturally interfaces with the default sitemap record (web.sitemap).

Click here to see a demo of Menu, TreeView, and SiteMapPath


TreeView

The <asp:TreeView> control shows a staggered route menu.

The menu resembles a tree with branches that can be opened or shut with + or - image.

Code Example:

<asp:SiteMapDataSource id="nav1" runat="server"/>

<form runat="server">
<asp:TreeView runat="server" DataSourceId="nav1"/>
</form>

The <asp:TreeView> control in the precedent above is a placeholder for a server made route menu.

The information wellspring of the control is characterized by the DataSourceId trait. The id="nav1" interfaces it to the  <asp:SiteMapDataSource> control.

The <asp:SiteMapDataSource> control naturally interfaces with the default sitemap document (web.sitemap).

Click here to see a demo of Menu, TreeView, and SiteMapPath


SiteMapPath

The SiteMapPath control shows the trail (route way) to the present page. The way goes about as interactive connects to past pages.

Unlike the TreeView and Menu control the SiteMapPath control does NOT utilize a SiteMapDataSource. The SiteMapPath control utilizes the web.sitemap record by default.

Code Example:

<form runat="server">
<asp:SiteMapPath runat="server"/>
</form>

The <asp:SiteMapPath> control in the precedent above is a placeholder for a server made site way display.

Click here to see a demo of Menu, TreeView, and SiteMapPath