VisualStudioFeeds

All Visual Studio blogs in one place

AddThis Social Bookmark Button
I am using the Razor view engine for this example; in Visual Studio 2010 with MVC 3 web application template. For more explanation, check out Scott Guthrie‘s blog here or here or one of the other many great posts he has written.
I like to use the SiteMap control for an easy horizontal navigation menu at the top of the content area and styled like a tab interface. Adding a few thin borders and the right background colors can create a great tab effect.
The new Razor view engine makes it very
easy to create dynamic templates.

- Create a SiteMap in the root directory of your web application and add some nodes

- Create an App_Code folder in your solution if you do not have one already

- Add a new blank partial view file called Helpers.cshtml in the App_Code folder

- Enter the following into the file -
@helper SiteMapHelper() {
   

            @{
            SiteMapNodeCollection topLevelNodes = SiteMap.RootNode.ChildNodes;
            }
            @foreach (SiteMapNode node in topLevelNodes)
            {
           
  •             {
                    class="selectedMenuItem"
                }
                >
            @node.Title

Search

Subscribe

Enter your email address:

Delivered by FeedBurner

Increase your website traffic with Attracta.com

Contact

Email:
Subject:
Message:
Anti-spam: How many eyes has a typical person?

Follow us on FB

Home : Blog List : Michael Bridge : ASP.NET MVC 3 Hosting :: MVC3 Helper for Tabbed Navigation