Sortable Hierarchical Menu Control (code included)

Topics: Controls
Nov 8, 2007 at 3:23 PM
Edited Nov 9, 2007 at 7:19 AM
Fellas!

I have modified my menucontrol a bit.
It is now sortable on different variables, and the menu is cachable for extra speed.
Please visit my site for example and download.

Comments are appreciated.

http://www.jonah.carneskog.com/post/Blogengine-Menu-Usercontrol.aspx

Cheers!
- jonah
Mar 27, 2009 at 10:52 PM
Hi Jonah!

Can this menu control replace the top-level menu of the Blog Engine? If so, how do I modify the menu in the site.master to create child menus like you have on your web site.

It would be nice to see a chuck of code of your modification to the standard code.

Thanks!
Mar 28, 2009 at 9:57 AM
Hi there!

The control generates an unordered list, and styling can be done in many different ways. There are a lot of examples on the web on how to style a menu from an unordered list.
The code should be pretty self-explanatory. Please download it and take a look.

Cheers!
 - jonah
Apr 12, 2009 at 10:38 PM
How to style a menu from an unordered list -  that is what I'm having trouble with. Do you mind showing me your CSS for the drop-down menu for your blog? Thanks!
Feb 5, 2011 at 10:11 PM

I believe i have found a bug (the bug?) in the code for this control that prevents it from rendering in IE8 and higher.

Lines 362-366 are as follows:

                    if (SubMenuStarted)
                    {
                        // Clean up - Need to close the tag.
                        sb.Append("</li></ul>\n");
                    }

This creates an extra "</li>" tag, which creates invalid code. This, in turn prevents the menu from rendering anything except the Home and Categories tabs (in my experience).

Change is section to read:
                    if (SubMenuStarted)
                    {
                        // Clean up - Need to close the tag.
                        sb.Append("</ul>\n");
                    }

The code now renders and validates perfectly.

Aug 26, 2011 at 2:33 PM

I still really like this menu control.

With the changes in BlogEngine 2.5, "BlogSettings.Instance.FileExtension" needs to be changed to "BlogConfig.FileExtension".