I'm creating a menu for my web site. It's got a hierarchical structure.
Here's what I want:
- Great Grandparent
- Grandparent
- Parent
- Sibling1
- Sibling2
- Sibling3
- Self
- Child1
- Child2
- Child3
- Parent
- Grandparent
HTML:
<ul>
<li><a href="/389">Great Grandparent</a>
<ul>
<li><a href="/456">Grandparent</a>
<ul>
<li><a href="/389">Parent</a>
<ul>
<li><a href="/986">Sibling1</a></li>
<li><a href="/983">Sibling2</a></li>
<li><a href="/418">Sibling3</a></li>
<li><strong>Self</strong>
<ul>
<li><a href="/310">Child1</a></li>
<li><a href="/953">Child2</a></li>
<li><a href="/927">Child3</a></li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
</ul>
Here's the code from my ASPX page. This works:
<% For Each Ancestor As Node In ViewData("Ancestors")%>
<ul>
<li><%=Html.RouteLink(Html.Encode(Ancestor.Name), "IdOnly", New With {.id = Ancestor.Id})%>
<% Next%>
<ul>
<% For Each Sibling As Node In ViewData("Siblings")%>
<li><%=Html.RouteLink(Html.Encode(Sibling.Name), "IdOnly", New With {.id = Sibling.Id})%></li>
<% Next%>
<li><strong><%=Html.Encode(Model.Name)%></strong>
<% If Model.Children.Count > 0 Then%>
<ul>
<% For Each Child As Node In ViewData("Children")%>
<li><%=Html.RouteLink(Html.Encode(Child.Name), "IdOnly", New With {.id = Child.Id})%></li>
<% Next%>
</ul>
<% End If%>
</li>
</ul>
<% For Each Ancestor As Node In ViewData("Ancestors")%>
</li>
</ul>
<% Next%>
That ASPX page seems pretty hard to read. How can I clean that up?