View Full Version : Dynamic Accordion Menu

02-27-2008, 12:13 PM
1) Accordion Menu script

2) http://www.dynamicdrive.com/dynamicindex17/ddaccordionmenu.htm

Having problems to populate my dynamic ASP.NET menu with the
accordion menu.

Here is my code:

<%@ Control Language="C#" %>

<%@ Register Assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
Namespace="System.Web.UI" TagPrefix="asp" %>

<script type="text/javascript" src="http://www.ergona.se/js/accordion/jquery-1.2.2.pack.js"></script>
<script type="text/javascript" src="http://www.ergona.se/js/accordion/ddaccordion.js"></script>

<script type="text/javascript">

headerclass: "expandable", //Shared CSS class name of headers group that are expandable
contentclass: "categoryitems", //Shaared CSS class name of contents group
collapseprev: true, //Collapse previous content (so only one open at any time)? true/false
defaultexpanded: [], //index of content(s) open by default [index1, index2, etc]. [] denotes no content
animatedefault: false, //Should contents open by default be animated into view?
persiststate: true, //persist state of opened contents within browser session?
toggleclass: ["", "openheader"], //Two CSS classes to be applied to the header when it's collapsed and expanded, respectively ["class1", "class2"]
togglehtml: ["none", "", ""], //Additional HTML added to the header when it's collapsed and expanded, respectively ["position", "html1", "html2"] (see docs)
animatespeed: "normal" //speed of animation: "fast", "normal", or "slow"


<img src="http://www.ergona.se/App_Themes/Ergona/images/hl_sortiment.png" alt="" width="143" height="32"/>

<div class="arrowlistmenu">


//Using the Site's static category collection (created in Global.asax OnAppStart)
//showing only parent and direct child however feel free to use whatever makes
//sense to you

foreach (Commerce.Common.Category cat in CategoryController.CategoryList)

if (cat.ParentID == 0)


<div class="menuheader expandable">
<a href="<%=Utility.GetRewriterUrl("catalog",cat.CategoryGUID.ToString() ,"")%>"><%=cat.CategoryName%></a>

<ul class="categoryitems">

//get the kids
foreach (Commerce.Common.Category subCat in CategoryController.CategoryList)
if (subCat.ParentID == cat.CategoryID)


<a href="<%=Utility.GetRewriterUrl("catalog",subCat.CategoryGUID.ToString(),"")%>"><%=subCat.CategoryName%></a>





02-27-2008, 10:45 PM
I don't know ASP, but in general, the checklist for using any server side language to dynamically output client side JavaScripts is the same. As long as what gets output to the browser conforms to the syntax/ conventions of the client side script, as if you've manually added it to the page, it should work.