ASP.NET Navigation
Tutorial -- Learning is not just about technology, but also about dreams!
- Home
- HTML
- JavaScript
- CSS
- Vue
- React
- Python3
- Java
- C
- C++
- C#
- AI
- Go
- SQL
- Linux
- VS Code
- Bootstrap
- Git
- Local Bookmarks
ASP.NET Tutorial
ASP.NET Tutorial ASP.NET Introduction
WP Tutorial
WebPages Introduction WebPages Razor WebPages Layout WebPages Folders WebPages Global WebPages Forms WebPages Objects WebPages Files WebPages Helpers WebPages WebGrid WebPages Charts WebPages Email WebPages PHP WebPages Publishing WebPages Examples
WP Reference Manual
WebPages Classes WebPages Security WebPages Database WebPages WebMail WebPages Helpers
ASP.NET Razor
Razor Introduction Razor Syntax Razor C# Variables Razor C# Loops Razor C# Logic Razor VB Variables Razor VB Loops Razor VB Logic
ASP.NET MVC
MVC Introduction MVC Application MVC Folders MVC Layout MVC Controllers MVC Views MVC Database MVC Models MVC Security MVC HTML Helpers MVC Publishing MVC Reference Manual
WF Tutorial
WebForms Introduction WebForms Pages WebForms Controls WebForms Events WebForms Forms WebForms ViewState WebForms TextBox WebForms Button WebForms Data Binding WebForms ArrayList WebForms Hashtable WebForms SortedList WebForms XML Files WebForms Repeater WebForms DataList WebForms Database Connection WebForms Master Pages WebForms Navigation WebForms Examples
WF Reference Manual
WebForms HTML WebForms Controls WebForms Validation
ASP.NET Web Forms - Navigation
ASP.NET comes with built-in navigation controls.
Website Navigation
Maintaining menus for a large website is difficult and time-consuming.
In ASP.NET, menus can be stored in a file, making them easy to maintain. The file is typically named web.sitemap and is stored in the root directory of the website.
Additionally, ASP.NET has three new navigation controls:
- Dynamic menus
- TreeViews
- Site Map Path
Sitemap File
In this tutorial, the following sitemap file is used:
Rules for creating a sitemap file:
- The XML file must contain tags surrounding the content
- The tag can only have one child node (the "home" page)
- Each can have multiple child nodes (web pages)
- Each has attributes that define the page title and URL
Note: The sitemap file must be located in the site's root directory, and the URL attribute must be relative to that root directory.
Dynamic Menus
The control can display a standard site navigation menu.
Code Example:
The control in the example above is a placeholder for the server to create a navigation menu.
The data source for the control is defined by the DataSourceId attribute. id="nav1" connects the data source to the control.
The control automatically connects to the default sitemap file (web.sitemap).
TreeView
The control can display a multi-level navigation menu.
This kind of menu looks like a tree with branches and leaves, which can be opened or closed using + or - symbols.
Code Example:
The control in the example above is a placeholder for the server to create a navigation menu.
The data source for the control is defined by the DataSourceId attribute. id="nav1" connects the data source to the control.
The control automatically connects to the default sitemap file (web.sitemap).
SiteMapPath
The SiteMapPath control can display a pointer (navigation path) to the current page. The path is shown as clickable links pointing to parent pages.
Unlike the TreeView and Menu controls, the SiteMapPath control does not use SiteMapDataSource. The SiteMapPath control uses the web.sitemap file by default.
Tip: If SiteMapPath is not displaying correctly, it is most likely due to a URL error (typo) in the web.sitemap file.
Code Example:
The control in the example above is a placeholder for the server to create a navigation menu.
YouTip