开发者

How to create dynamic menu in asp.net mvc?

How to create dynamic menu开发者_StackOverflow中文版 on views in asp.net mvc 2.0?


Could you be a bit more spesific maybe?

If it's just a list of links it's easy enough, you just loop trough them an output a link with the Html.Action helper.

Something like:

<div class="menu">
<% // From the Controller we got the following list of links as a IEnumerable<String> { "Home", "About" } put in Model.
foreach(var lAddr in Model) { %>
    <%= Html.Action(lAddr, lAddr) %><br />
<% } %>
</div>

This should hender something like (if in an Controller named Home):

<a href="/Home/Home">Home</a><br /><a href="/Home/About">About</a>


Use JQuery menu.

http://p.sohei.org/stuff/jquery/menu/demo/demo.html

Use controller to build ViewData for menu. Build the Menu in view by iterating over the ViewData for Menu.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜