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 8156031
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T16:49:58+00:00 2026-06-06T16:49:58+00:00

I’m trying to make a ul/li menu in my ASP.NET MVC application. The menu

  • 0

I’m trying to make a ul/li menu in my ASP.NET MVC application. The menu should have 4 to 5 top menu items and each topmenu item should have a hover/dropdown menu with some submenu items. The finished menu structure should look like a usual ul/li menu with dropdown:

<ul>

 <li class="active">
   <a>Topmenu 1</a>
   <ul>
   <li>Submenu1</li>
   <li>Submenu2</li>
   <li>Submenu3</li>
   </ul>
 </li>

  <li class="inactive">
   <a>Topmenu 2</a>
   <ul>
   <li>Submenu4</li>
   <li>Submenu5</li>
   <li>Submenu6</li>
   </ul>
 </li>
  And so on...
</ul> 

The top menu items should have classes with “active” and “inactive”. I solved that problem by making a custom HtmlHelper which generates the topmenu items. That looks like this:

 public static MvcHtmlString MenuItem(
    this HtmlHelper htmlHelper,
    string text,
    string action,
    string controller
)
    {

        var li = new TagBuilder("li");
        var routeData = htmlHelper.ViewContext.RouteData;
        var currentAction = routeData.GetRequiredString("action");
        var currentController = routeData.GetRequiredString("controller");
        if (string.Equals(currentAction, action, StringComparison.OrdinalIgnoreCase) &&
            string.Equals(currentController, controller, StringComparison.OrdinalIgnoreCase))
        {
            li.AddCssClass("tab active");
        }
        else {
            li.AddCssClass("tab inactive");
        }
        li.InnerHtml = htmlHelper.ActionLink(text, action, controller).ToHtmlString();
        return MvcHtmlString.Create(li.ToString());
    }

I call the function like this:

@Html.MenuItem("Katalog", "Index", "Katalog")

This function works very well. Unfortunately the whole topmenu <li> item is getting generated. So I have no posibility to place the <ul> for the submenuitems somewhere in the topmenu <li> tag.

Does someone have an idea how to make a menu like that? Or an idea how I can get my <ul> into the topmenu <li> tag?

  • 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-06-06T16:49:59+00:00Added an answer on June 6, 2026 at 4:49 pm

    You could use something like Superfish menu. I use it and it’s pretty good. The only thing you have to have is the structure of your menu somewhere in your view (_Layout.cshtml for example). If you choose to go this way, just create the menu structure (<ul><li>) by hand and call the Superfish jQuery plugin. You’ll get an awesome menu ready to use no matter how many nesting levels (<ul> inside <li>) your menu may have. The plugin will handle it nicely.

    Sample code:

    <script type="text/javascript" src="superfish.js"></script>
    
    // Create the root <ul> with id = menu... <ul id="menu">
    // Call superfish() on the containing ul element.
    
    <script> 
    
        $(document).ready(function() { 
            $('ul#menu').superfish(); 
        }); 
    
    </script>
    

    You can customize the menu with lots of options like this:

    <script> 
    
        $(document).ready(function() { 
            $('ul#menu').superfish({ 
                delay:       1000,                            // one second delay on mouseout 
                animation:   {opacity:'show',height:'show'},  // fade-in and slide-down animation 
                speed:       'normal',                        // faster animation speed 
                autoArrows:  true,                            // enable generation of arrow mark-up 
                dropShadows: true                             // enable drop shadows 
            }); 
        }); 
    
    </script>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Basically, what I'm trying to create is a page of div tags, each has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have an MVC Razor view @{ ViewBag.Title = Index; var c = (char)146;
I am trying to loop through a bunch of documents I have to put
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
I am trying to understand how to use SyndicationItem to display feed which is
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
this is what i have right now Drawing an RSS feed into the php,
I am trying to render a haml file in a javascript response like so:

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.