|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
|
Announcements
Chapters
Services
Feature Zones
|
Note: This is an unedited contribution. If this article is inappropriate,
needs attention or copies someone else's work without reference then please
Report This Article
IntroductionMaybe you hear about http://www.opencube.com/ and their menu projects.. Cool, really cool. BUT their cool menu stays on its own. So 2 classes were implemented to learn their menu 'talk' with Web.sitemap file of ASP .NET web application. This menu is generated using HTML comfortable class Working example you can see on personal page: ykorotia.eu Using the codeTest & working page with their menu: ======== Default.aspx =======
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<link href="OpenCube_QuickMenu/1.css" rel="stylesheet" type="text/css" />
<script src="OpenCube_QuickMenu/MenuInit.js" type="text/javascript"></script>
<script src="OpenCube_QuickMenu/Core.js" type="text/javascript"></script>
<script src="OpenCube_QuickMenu/Add-On/RoundedItems.js" type="text/javascript"></script>
<script src="OpenCube_QuickMenu/Add-On/RoundedCorners.js" type="text/javascript"></script>
<script src="OpenCube_QuickMenu/Add-On/MergeAnimation.js" type="text/javascript"></script>
</head>
<body>
<form id="form1" runat="server">
<div>
<%=ykorotia_eu.OpenCube.QuickMenu.GetMenuFromSitemap() %>
<script type="text/javascript">
qm_create(0, false, 0, 500, false, false, false, false, false);
</script>
DEFAULT
</div>
</form>
</body>
</html>
In background Menu looks like this: ==== QuickMenu.cs ====
public static string GetMenuFromSitemap()
{
SitemapLevel lvl = SitemapLevel.three;
string qmDivider = "[qmDivider]";
string qmTitle = "[qmTitle]";
string qmCss_Parent = "qmparent";
StringBuilder sb = new StringBuilder();
ykorotia_eu.Web.HTMLwriter wri = new ykorotia_eu.Web.HTMLwriter();
//prelude
//<ul id="qm0" class="qmmc"
sb.Append(wri.AddTag("ul","qmmc","", "qm0"));
// Doing from ROOT and so on
//p.s. Root node is hidden
if (SiteMap.RootNode.HasChildNodes && lvl >= SitemapLevel.one)
{ ........
where To enable features like 'title', 'divider line', here description parameter is used: ==== Web.sitemap ====
<?xml version="1.0" encoding="utf-8" ?>
<siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0" >
<siteMapNode url="~/" title="root" description="">
<siteMapNode url="~/1/1.aspx" title="I-CONTENT" description="">
<siteMapNode title="Online Tools" url="~/1" description="[qmTitle] | [qmDivider]" />
<siteMapNode title="Online Tools" url="~/1/" >
<siteMapNode title="IPv4toNumber" url="~/1/2.aspx"/>
</siteMapNode>
</siteMapNode>
</siteMapNode>
</siteMap>
Deepest html generation starts in HTMLwriter.cs Web.sitemap needs to have unique urls, but sometimes first links in menu should be non-clickable. You can gain it by placing this code in QuickMenu.cs : .....
// Doing from ROOT and so on
//p.s. Root node is hidden
if (SiteMap.RootNode.HasChildNodes && lvl >= SitemapLevel.one)
{
//=== 1st LEVEL ===
#region 1st level
foreach (SiteMapNode child_nodes1 in SiteMap.RootNode.ChildNodes)
{
// main menu nodes
sb.Append(wri.AddTag("li") + wri.AddLink(child_nodes1.Title,
//child_nodes1.Url - ignoring url in web.sitemap
"javascript:void(0);",
qmCss_Parent, "", false));
.....
HistoryFirst version. Added some tip Platinum members can improve this article. Article is under GNU GPL, willing to leave open source open. Logically?
|
||||||||||||||||||||||