asp.net MVC 数据库驱动的导航菜单
有人能指出我如何实现由数据库驱动的分层导航菜单的正确方向吗?我不想在这里重新发明轮子,所以我想知道是否已经做了一些事情。我知道 asp.net 中的菜单控件,但据我所知,它不适用于 MVC。是否有一些已经作为框架的一部分提供的东西可供我用于此目的?如果没有,那么也许有一些链接可以为我指明正确的方向?
谢谢。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
LBushkin的想法是好的。有关从数据库发出
和
标记的方法,请查看以下博客文章:
ASP.NET MVC 递归树视图助手
http://www.matthidinger.com/archive/2009/02/08/asp.net-mvc-recursive-treeview-helper.aspx" matthidinger.com/archive/2009/02/08/asp.net-mvc-recursive-treeview-helper.aspx
使用 ASP.NET MVC 框架呈现 TreeView
http://mikehadlow.blogspot.com/ 2008/10/rendering-tree-view-using-mvc-framework.html
我个人使用 Matt Hidinger 的递归 TreeView Helper 的修改版本,并为其提供几个
IQueryable
我的数据库。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
IQueryable
s from my database.你可能想看看 superfish - 它是一个 jQuery灵活且使用语义标记的兼容菜单控件。您可以通过发出一组适当的
和
标签来菜单。甚至可以通过将列表嵌套在其他列表中来嵌套它们以创建分层菜单。
它不直接与数据库表示交互 - 但很容易将这样的结构作为
标签发送到标记中并将 superfish 应用于它。
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.