Hi,
I'm making a website with an Accordion Navigation menu. Some of my menuitems has childNodes so that's no problem but some of my nodes doesn't have childnodes. So it should be possible when I click on that header that I open an other page.
This is my code up till now! But still nothings happen Can somebody help me please?
This is the asp page
<asp:panel ID="Menu" runat="server" CssClass="pnlMenu"><ajaxToolkit:Accordion ID="myAccordion" runat="server" SuppressHeaderPostbacks="true" /></asp:panel>
This is the Javascript on this page
<script type="text/javascript" language="javascript"> function headerOnClick(url) { window.location.href = url; }</script>
This is the code behind the page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load AccordionSiteMap_Load(sender, e) AccordionSiteMap_OpenCurrentPane(sender, e)End Sub Protected Sub AccordionSiteMap_Load(ByVal sender As Object, ByVal e As EventArgs)Dim p As New AjaxControlToolkit.AccordionPaneDim linkClass, currentLinkClass, nonCurrentLinkClass As String linkClass = "" currentLinkClass = "AccordionCurrentLink" nonCurrentLinkClass = "AccordionLink"If SiteMap.RootNode.HasChildNodes Then Dim RootNodesEnumerator As IEnumerator = SiteMap.RootNode.ChildNodes.GetEnumerator()Dim paneCounter As Integer = 0While RootNodesEnumerator.MoveNext p = Nothing p = New AjaxControlToolkit.AccordionPane p.ID = "Pane"& Regex.Replace(RootNodesEnumerator.Current.ToString(), "\s+", "")Dim stLink As String = ""If RootNodesEnumerator.Current.url.Equals("") Then stLink = "<a>"& RootNodesEnumerator.Current.Title & "</a>"Else stLink = "<a onclick='headerOnClick(" & RootNodesEnumerator.Current.url & ")'>" & RootNodesEnumerator.Current.Title & "</a>" End If p.HeaderContainer.Controls.Add(New LiteralControl(stLink)) If RootNodesEnumerator.Current.HasChildNodes Then Dim ChildNodesEnumerator As IEnumerator = RootNodesEnumerator.Current.ChildNodes.GetEnumerator() While ChildNodesEnumerator.MoveNext If SiteMap.CurrentNode Is Nothing Then linkClass = nonCurrentLinkClass ElseIf SiteMap.CurrentNode.ToString = ChildNodesEnumerator.Current.ToString Then linkClass = currentLinkClass Else linkClass = nonCurrentLinkClass End If p.ContentContainer.Controls.Add(New LiteralControl("<a class='" & linkClass & "' ")) p.ContentContainer.Controls.Add(New LiteralControl("href='" & ChildNodesEnumerator.Current.url & "'>")) p.ContentContainer.Controls.Add(New LiteralControl(ChildNodesEnumerator.Current.title & "</a><br />"))End While End If myAccordion.Panes.Add(p)End While End If End Sub Protected Sub AccordionSiteMap_OpenCurrentPane(ByVal sender As Object, ByVal e As EventArgs)If SiteMap.CurrentNode Is Nothing Then myAccordion.SelectedIndex = -1Else myAccordion.SelectedIndex = RootIndexofCurrentNode(SiteMap.RootNode.ChildNodes)End If End Sub Private Function RootIndexofCurrentNode(ByVal Nodes As SiteMapNodeCollection) As Short Dim index As Short = -2If Nodes Is Nothing Then RootIndexofCurrentNode = -1ElseIf Nodes.Contains(SiteMap.CurrentNode) Then RootIndexofCurrentNode = Nodes.IndexOf(SiteMap.CurrentNode)Else For Each n As SiteMapNode In Nodes index = RootIndexofCurrentNode(n.ChildNodes)If index <> -1 Then If n.ParentNode.ToString = SiteMap.RootNode.ToString Then Return SiteMap.RootNode.ChildNodes.IndexOf(n)Else Return indexEnd If End If Next Return -1End If End Function