Navigation Controls
Navigation Controls
ASP.NET provides a number of controls that can be added to Web forms pages. These controls are also
known as server-side controls or server controls. They are available in namespace
System.Web.UI.WebControls.
In ASP.NET 2.0, a menu can be stored in a file to make it easier to maintain. This file is normally called
web.Sitemap, and is stored in the root directory of the web.
Dynamic menus
Tree Views
It was the very difficult task to maintain the menu of a large website and time consuming. It is used to
display the Menus. You can use it as easy as other Navigation controls. Menu can be stored in a file to
make it easier to maintain. This file is normally called web. Sitemap, and is stored in the root directory of
the web.
Example:
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<div>
<DynamicItemTemplate>
Audio songs
<br />
Video songs
<br />
</DynamicItemTemplate>
<StaticItemTemplate>
Songs
<br />
</StaticItemTemplate>
<Items>
</asp:MenuItem>
</Items>
</asp:Menu>
</div>
</form>
</body>
</html>
A Tree View control displays a hierarchical list of items using lines to connect related items in a
hierarchy. Each item consists of a label and an optional bitmap. Windows Explorer uses a Tree View
control to display directories. You can use the Tree View control in any situation in which you need to
display hierarchical data.
Example: We want to create the Employee's information in the hierarchical structure by using the Tree
View control.
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<div>
<table bgcolor="#ffccff">
<tr>
<td>
NodeIndent="10">
<ParentNodeStyle Font-Bold="False" />
VerticalPadding="0px" />
<Nodes>
</asp:TreeNode>
</asp:TreeNode>
</asp:TreeNode>
</asp:TreeNode>
</Nodes>
</asp:TreeView>
</td>
</tr>
</table>
</div>
</form>
</body>
</html>
treeview.bmp
Use of this control is very simple. You can add this control to your page then view your page in browser.
The Sitemap Path control displays the navigation path of the current page. The path acts as click able
links to previous pages.
The Sitemap Path control uses the web. Sitemap file by default.
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<div>
Height="40px" Width="400px">
</asp:SiteMapPath>
</div>
</form>
</body>
</html>
Design view of the Site map Path:
sitemap.bmp