ASP.NET(vb.net) & SiteMapDataSource - asp:SiteMapDataSource - The SiteMapDataSource provides a data source control that Web server controls and other controls can use to bind to hierarchical site map data.
ShotDev Focus:
- ASP.NET(vb.net) & SiteMapDataSource - asp:SiteMapDataSource
Tag Control :
<asp:SiteMapDataSource ID="SiteMapDataSource1" runat="server"></asp:SiteMapDataSource>
On current project Right Click -> Add New Item…
Select SiteMap Item.
<?xml version="1.0" encoding="utf-8" ?> <siteMap> <siteMapNode title="Home" url="~/Default.aspx" roles="*"> <siteMapNode title="Services" url="~/Services.aspx " > <siteMapNode title="Training" url="~/Training.aspx" /> </siteMapNode> <siteMapNode title="Products" url="" /> </siteMapNode> </siteMap>
Create Sitemap (Web.sitemap)
DragĀ TreeView Control to ASP.NET Web Form. On TreeView Tasks -> Choose Data Source (SiteMapDataSource)
Example Code
Default.aspx
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>ShotDev.Com Tutorial</title> </head> <body> <form id="form1" runat="server"> <div> <asp:SiteMapDataSource ID="SiteMapDataSource1" runat="server" /> <asp:TreeView ID="TreeView1" runat="server" DataSourceID="SiteMapDataSource1"> </asp:TreeView> </div> </form> </body> </html>
QueryExtender.aspx.vb
Partial Class _Default Inherits System.Web.UI.Page End Class
Screenshot