Help with a 2level horizontal menu with MVC3 and razor
I am trying to do a 2-level horizontal menu, like the one found here: TV.Com
I have searched on google but cant get it together.
Here's the sample i am using:
<div id="divNav">
<ul id="nav">
<li id="liRenaissance" class="off"><a href="#"><span&g开发者_StackOverflowt;Renaissance</span></a>
<ul>
<li><a href="#">Brunelleschi</a></li>
<li><a href="#">Alberti</a></li>
<li><a href="#">Palladio</a></li>
<li><a href="#">Michelangelo</a></li>
<li><a href="#">Bramante</a></li>
</ul></li>
<li id="liModern" class="on"><a href="#"><span>Modern</span></a>
<ul>
<li><a href="#">Sullivan</a></li>
<li><a href="#">Le Corbusier</a></li>
<li><a href="#">Mies</a></li>
<li><a href="#">Gropius</a></li>
<li><a href="#">Yamasaki</a></li>
</ul></li>
The CSS is working, but how can i set this from the controller without using Request.Querystring.
Hope anyone can help me!
This might make your life a bit easier: ASP.NET MVC Sitemap provider
Based on your markup, I'm guessing you want to be able to set one of the menus to "on" and the other to "off" based upon your location on the site.
If you are reluctant to use the Request.Querystring within the masterpage itself, you could:
Use a codebehind on your master page This is a bit outdated, as codebehinds are avoided within MVC, however it would work in separating your concerns for a masterpage which typically has no controller.
Use a RenderAction to reference a controller which will handle menu generation.
Number 2 is probably your best bet.
精彩评论