The same code works fine with MVC 2, but does not work in MVC 3 Razor. After loading the page, the menu does not load from the HTMLHelper called in Razor, as shown below.
Hard menu for testing, which is not displayed on the page.
using System.Collections.Generic;
using System.Web.Mvc;
using System.Web.Mvc.Html;
using myproject.Extensions;
public static class MenuHelper
{
public static string TabbedMenu(this HtmlHelper helper, IEnumerable<MenuTab> tabs)
{
//I have hard coded menu for testing purpose.
return "<div class='menu-image'><img src='/content/Images/common/on-left.gif' alt='' /></div><div class='on'><a class='over' href='/?Length=4'>Home</a></div><div class='menu-image'><img src='/content/Images/common/on-right.gif' alt='' /></div><a href='/Home/About'>About</a><a href='/Home/Contact'>Contact</a>";
}
}
Below is the RHR CSHTML code.
@{Html.TabbedMenu
(
new List<MenuTab>
{
MenuTab.Create("Home", "Index", "Home"),
MenuTab.Create("About", "About", "Home"),
MenuTab.Create("Contact", "Contact", "Home")
}
);}
source
share