开发者

asp.net MVC database driven navigation menu

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 al开发者_如何学运维ready 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.


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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜