SiteMapDataSource.aspx
<?xml version="1.0" encoding="utf-8" ?>
<siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0" >
<siteMapNode url="Default.aspx" title="Home" description="Home Page">
<siteMapNode url="StandardToolBox.aspx" title="StandardToolBox" description="StandardToolBox Controls">
<siteMapNode url="AdRotatorExample.aspx" title="AdRotator" description="AdRotator Example" />
<siteMapNode url="BulletedListExample.aspx" title="BulletedList" description="BuulletedList Example" />
<siteMapNode url="ButtonExample.aspx" title="Button" description="Button Example" />
<siteMapNode url="CalendarExample.aspx" title="Calendar" description="Calendar Example" />
</siteMapNode>
<siteMapNode url="DataToolBox.aspx" title="DataToolBox" description="DataToolBox controls">
<siteMapNode url="ListViewExample.aspx" title="ListView" description="ListView Example" />
<siteMapNode url="GridViewExample.aspx" title="GridView" description="GridView Example" />
</siteMapNode>
<siteMapNode url="NavigationToolbox.aspx" title="Navigation Toolbox" description="NavigationToolbox controls">
<siteMapNode url="MenuExample.aspx" title="Menu" description="Menu Example" />
<siteMapNode url="SiteMapPathExample.aspx" title="SiteMapPath" description="SiteMapPath Example" />
<siteMapNode url="TreeViewExample.aspx" title="TreeView" description="TreeView Example" />
</siteMapNode>
</siteMapNode>
</siteMap>
<%@ Page Language="C#" %>
<script runat="server">
protected void Button1_Click(object sender, System.EventArgs e)
{
SiteMapDataSource1.ShowStartingNode = false;
}
protected void Button2_Click(object sender, System.EventArgs e)
{
SiteMapDataSource1.ShowStartingNode = true;
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>How to use ShowStartingNode property in SiteMapDataSource</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<h2 style="color:Navy">SiteMapDataSource Example</h2>
<asp:SiteMapDataSource ID="SiteMapDataSource1" runat="server"/>
<asp:TreeView
ID="TreeView1"
runat="server"
DataSourceID="SiteMapDataSource1"
Width="250"
BackColor="PaleVioletRed"
ForeColor="Wheat"
Font-Bold="true"
Font-Italic="true"
>
</asp:TreeView>
<br />
<asp:Button
ID="Button1"
runat="server"
ForeColor="SaddleBrown"
Text="ShowStartingNode False"
Height="45"
OnClick="Button1_Click"
Font-Bold="true"
/>
<asp:Button
ID="Button2"
runat="server"
ForeColor="SaddleBrown"
Text="ShowStartingNode True"
Height="45"
OnClick="Button2_Click"
Font-Bold="true"
/>
</div>
</form>
</body>
</html>
Asp.Net Web.sitemap Example: a sample Web.sitemap file
<?xml version="1.0" encoding="utf-8" ?>
<siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0" >
<siteMapNode url="Default.aspx" title="Home" description="Home Page">
<siteMapNode url="StandardToolBox.aspx" title="StandardToolBox" description="StandardToolBox Controls">
<siteMapNode url="AdRotatorExample.aspx" title="AdRotator" description="AdRotator Example" />
<siteMapNode url="BulletedListExample.aspx" title="BulletedList" description="BuulletedList Example" />
<siteMapNode url="ButtonExample.aspx" title="Button" description="Button Example" />
<siteMapNode url="CalendarExample.aspx" title="Calendar" description="Calendar Example" />
</siteMapNode>
<siteMapNode url="DataToolBox.aspx" title="DataToolBox" description="DataToolBox controls">
<siteMapNode url="ListViewExample.aspx" title="ListView" description="ListView Example" />
<siteMapNode url="GridViewExample.aspx" title="GridView" description="GridView Example" />
</siteMapNode>
<siteMapNode url="NavigationToolbox.aspx" title="Navigation Toolbox" description="NavigationToolbox controls">
<siteMapNode url="MenuExample.aspx" title="Menu" description="Menu Example" />
<siteMapNode url="SiteMapPathExample.aspx" title="SiteMapPath" description="SiteMapPath Example" />
<siteMapNode url="TreeViewExample.aspx" title="TreeView" description="TreeView Example" />
</siteMapNode>
</siteMapNode>
</siteMap>
No comments:
Post a Comment