May 12, 2021 ASP.NET
ASP.NET with built-in navigation controls.
Maintaining menus on large websites is difficult and time-consuming.
In ASP.NET, menus can be stored in files, making them easy to maintain. The file is usually called web.sitemap and is stored at the root of the Web site.
In addition, ASP.NET has three heart navigation controls:
For this tutorial, use the following sitemap file:
Rules for creating sitemap files:
Note: The sitemap file must be under the site root, and the URL property must be relative to the root.
The control displays a standard site navigation menu.
Examples of code:
The control in the example above, slt;asp:Menu, is a placeholder for the server to create navigation menus.
The control's data source is defined by the DataSourceId property. id"nav1" connects the data source to the controls of the .lt;asp:SiteMapDataSource.
The SiteMapDataSource control automatically connects to the default sitemap file (web.sitemap).
The control displays a multi-level navigation menu.
This menu looks like a tree with branches and leaves, which can be opened or closed by the sign .
Examples of code:
The control in the example above, slt;asp:TreeView, is a placeholder for the server to create navigation menus.
The control's data source is defined by the DataSourceId property. id"nav1" connects the data source to the controls of the .lt;asp:SiteMapDataSource.
The SiteMapDataSource control automatically connects to the default sitemap file (web.sitemap).
The SiteMapPath control displays a pointer (navigation path) to the current page. The path appears as a clickable link to the parent page.
Unlike treeView and Menu controls, SiteMapPath controls do not use SiteMapDataSource. The SiteMapPath control uses the web.sitemap file by default.
Tip: If SiteMapPath doesn't display correctly, it's most likely due to a URL error (print error) in the web.sitemap file.
Examples of code:
The control in the example above, the siteMapPath, is a placeholder for the server to create navigation menus.
The above is about ASP.NET navigation, through the website navigation, you can quickly access a page.