5

can anybody point me in the right direction as to how I would go about implementing a hierarchical navigation menu which is driven by database? I don't want to re-invent the wheel here, so I was wondering if there is something that's already been done. I'm aware of the Menu control in asp.net, but from what I figure it won't work with MVC. Is there something that's already provided as part of the framework that I can leverage for this purpose? If not, then maybe a few links to point me in the right direction?

thanks.

2 Answers 2

3

LBushkin's idea is a good one. For ways to emit the <ul> and <li> tags from the database, have a look at the following blog posts:

ASP.NET MVC Recursive TreeView Helper
http://www.matthidinger.com/archive/2009/02/08/asp.net-mvc-recursive-treeview-helper.aspx

Rendering a TreeView using the ASP.NET MVC Framework http://mikehadlow.blogspot.com/2008/10/rendering-tree-view-using-mvc-framework.html

I personally use a modified version of Matt Hidinger's recursive TreeView Helper, and feed it a couple of IQueryables from my database.

Sign up to request clarification or add additional context in comments.

2 Comments

Is there any code for reading the data from database and populating the tree with LINQ to SQL or LINQ to ADO.Net entity?
2

You may want to look at superfish - it's a jQuery compatible menu control that's flexible and uses semantic markup. You can menus by just emitting an appropriate set of <ul> and <li> tags. They can even be nested to create hierarchical menus by just nesting lists within other lists.

It doesn't directly interface with a database representation - but it's easy enough to emit such a structure into markup as <ul> tags and apply superfish to it.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.