Monday, August 3, 2009

Simple Menu Example

A Simple Menu EG :-
<%@ Page Language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
<title>Menu SiteMap</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Menu
id="Menu1"
DataSourceID="srcSiteMap"
Runat="server" />
<asp:SiteMapDataSource
id="srcSiteMap"
Runat="server" />
</div>
</form>
</body>
</html>


Config for above SiteMap
Create an web.sitemap as give below

<?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="The home page of the Website">

<!-- SiteMapPath Nodes -->
<siteMapNode
title="Using the SiteMapPath Control"
description="Sample code for the SiteMapPath Control">
<siteMapNode
url="~/UsingSiteMapPath/DisplaySiteMapPath.aspx"
title="Displaying a SiteMapPath"
description="Sample code for displaying a SiteMapPath" />
<siteMapNode
url="~/UsingSiteMapPath/SiteMapPathStyle.aspx"
title="Using SiteMapPath Styles"
description="Sample code for using styles with SiteMapPath" />
<siteMapNode
url="~/UsingSiteMapPath/SiteMapPathTemplates.aspx"
title="Using SiteMapPath Templates"
description="Sample code for using templates with SiteMapPath" />
</siteMapNode>

<!-- Menu Nodes -->
<siteMapNode
title="Using the Menu Control"
description="Sample code for the Menu control">
<siteMapNode
url="~/UsingMenu/MenuSiteMap.aspx"
title="Displaying a Menu"
description="Sample code for displaying a Menu" />
</siteMapNode>

<!-- TreeView Nodes -->
<siteMapNode
title="Using the TreeView Control"
description="Sample code for the TreeView control">
<siteMapNode
url="~/UsingTreeView/TreeViewSiteMap.aspx"
title="Displaying a TreeView"
description="Sample code for displaying a TreeView" />
</siteMapNode>

</siteMapNode>

</siteMap>



Source ASP.NET Unleashed book 3.5

No comments:

Post a Comment