Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3432886
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T07:30:19+00:00 2026-05-18T07:30:19+00:00

This same code working fine with MVC 2 but not working in MVC 3

  • 0

This same code working fine with MVC 2 but not working in MVC 3 Razor. Once page is loaded not loading menu from HTMLHelper called within Razor like below.

Hardcoded menu for testing which is not outputting 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 Razor CSHTML code.

 @{Html.TabbedMenu
                        (
                            new List<MenuTab>
                            {
                                MenuTab.Create("Home", "Index", "Home"),
                                MenuTab.Create("About", "About", "Home"),
                                MenuTab.Create("Contact", "Contact", "Home")
                            }
                        );}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T07:30:20+00:00Added an answer on May 18, 2026 at 7:30 am

    Wrapping code in @{ ... } (like you did) is Razor’s equivalent to <% ... %> (without an =).

    Therefore, your code calls the function, but doesn’t do anything with the result.

    You should remove the {} and the ; and simply write @Html.TabbedMenu(...); this is equivalent to <%: Html.TabbedMenu(...) %>.

    You’ll also need to change the method to return an HtmlString to prevent Razor from escaping the HTML.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am getting this error on a remote server, but the same code executes
[This question is related to but not the same as this one .] My
[This question is related to but not the same as this one .] If
I'm trying to avoid code like this when reusing the same ViewUserControl in ASP.NET
The same as this question but for java Update Based on the comments and
This is the same question as this but I'm looking for a classic ASP
I saw this same question for VIM and it has been something that I
Whats this syntax useful for : function(String... args) Is this same as writing function(String[]
I'm trying a very basic XPath on this xml (same as below), and it
This question is pretty much the same as this .Net question exept for java.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.