The best ASP.NET navigation Tutorial In 2024, In this tutorial you can learn Site Navigation,Sitemap file,Dynamic menu,TreeView,SiteMapPath,
ASP.NET with built-in navigation controls.
Maintenance of large sites is difficult and time-consuming menu.
In ASP.NET, the menu can be stored in a file, so easy to maintain. File typically namedweb.sitemap, and is stored in the root directory of your site.
In addition, ASP.NET has three core navigation controls:
In this tutorial, we use the following sitemap file:
Create rules sitemap file:
Note: sitemap file must be located in the root directory of the site, URL attributes must be relative to the root directory.
<Asp: Menu> control displays a standard site navigation menu.
Code examples:
In the above example<asp: Menu> control is a placeholder for a server created navigation menu.
Data source controlsDataSourceId attribute definition.id = "nav1" data source to connect to the<asp: SiteMapDataSource>control.
<asp: SiteMapDataSource> control automatically connects to the default sitemap file (web.sitemap).
<Asp: TreeView> control displays a multi-level navigation menu.
This menu looks like a tree with branches that, by + or - sign to open or close.
Code examples:
In the above example<asp: TreeView> control is a placeholder for a server created navigation menu.
Data source controlsDataSourceId attribute definition.id = "nav1" data source to connect to the<asp: SiteMapDataSource>control.
<asp: SiteMapDataSource> control automatically connects to the default sitemap file (web.sitemap).
SiteMapPath control displays a pointer (navigation path) of the current page. The path appears to point to the parent page can click on the link.
With different controls TreeView and Menu, SiteMapPath controldoes not use the SiteMapDataSource.SiteMapPath control web.sitemap default file.
Tip: If the SiteMapPath is not displayed correctly, most likely due to the presence of URL errors (printing error) web.sitemap file.
Code examples:
In the above example<asp: SiteMapPath> control is a placeholder for a server created navigation menu.