Mega Code Archive

 
Categories / ASP.Net / Sitemap
 

Displaying the navigation information in a TreeView

<%@ Page Language="C#" %> <html xmlns="http://www.w3.org/1999/xhtml" > <head runat="server">     <title>Displaying the navigation information in a TreeView</title> </head> <body>     <form id="form1" runat="server">     <div>         <asp:SiteMapDataSource runat="Server" ID="SiteMapDataSource1" />                 <asp:TreeView DataSourceID="SiteMapDataSource1"                        runat="server"                       ID="tvwNavigation"                        ExpandImageUrl="Images/closed.gif"                        CollapseImageUrl="Images/open.gif">                     </asp:TreeView>         </div>     </form> </body> </html> File: Web.sitemap <?xml version="1.0" encoding="utf-8" ?> <siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0" >   <siteMapNode url="~/Default.aspx" title="Home">     <siteMapNode url="~/Default.aspx" title="Books">       <siteMapNode url="~/Novels.aspx" title="Novels" />       <siteMapNode url="~/History.aspx" title="History" />       <siteMapNode url="~/Romance.aspx" title="Romance" />     </siteMapNode>     <siteMapNode url="~/Default.aspx" title="Electronics">       <siteMapNode url="~/Cameras.aspx" title="Camera" />       <siteMapNode url="~/Computers.aspx" title="Computer" />     </siteMapNode>     <siteMapNode url="~/Default.aspx" title="DVDs">       <siteMapNode url="~/Horror.aspx" title="Horror" />       <siteMapNode url="~/Kids.aspx" title="Kids" />     </siteMapNode>     <siteMapNode url="~/Default.aspx" title="Computers">       <siteMapNode url="~/Desktop.aspx" title="Desktop" />       <siteMapNode url="~/Laptop.aspx" title="Laptop" />     </siteMapNode>   </siteMapNode> </siteMap>