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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T05:06:13+00:00 2026-06-18T05:06:13+00:00

I have an asp.net mvc4 solution. I have a menu on the left side.

  • 0

I have an asp.net mvc4 solution.

I have a menu on the left side. By default this menu is closed.

enter image description here

If I click on an item, a sub-menu is showed.

enter image description here

The problem is when I navigate to another page, the opened/closed state of sub-menus are forgotten. The new page is showed and all sub-menus are still closed. I would like to preserve the opend/closed state of these sub-menus. How can I proceed?

Here is a portion of my left side menu:

<div class="page-sidebar">
    <ul>
        <li class="dropdown" data-role="dropdown">
            <a><i class="icon-flip-2"></i> Transports</a>
            <ul class="sub-menu light sidebar-dropdown-menu">
                <li>@Html.ActionLink("En cours", "SearchTransportsAA", "Transp")</a></li>
                <li>@Html.ActionLink("Passés", "SearchTransportsBB", "Transp")</a></li>
                <li>@Html.ActionLink("Factures", "SearchTransportsCC", "Transp")</a></li>
            </ul>
        </li>
        <li class="dropdown" data-role="dropdown">
            <a><i class="icon-drawer-2"></i> Autorisations</a>
            <ul class="sub-menu light sidebar-dropdown-menu open">
                <li>@Html.ActionLink("Valides", "SearchAutorisAA", "Transp")</a></li>
                <li>@Html.ActionLink("Périmés", "SearchAutorisBB", "Transp")</a></li>
                <li>@Html.ActionLink("Recherche", "SearchAutorisCC", "Transp")</a></li>
            </ul>
        </li>
        ...
        ...

As you can see above, when ‘open’ is added to the class, the menu is marked to be open.

  • 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-18T05:06:14+00:00Added an answer on June 18, 2026 at 5:06 am

    One way you could do it, is to have your Views that have this side menu inherit from a model that have property that contains the selected sub-menu item

    public class ViewWithSideMenu
    {
        public ViewWithSideMenu(string menuItem)
        {
           MenuItem = menuItem;
        }
    
        public string MenuItem { get;set; }
    }
    

    ViewModel:

    public class MyViewmModel : ViewWithSideMenu
    {
        public MyViewmModel() : base("someMenu") {}
    }
    

    View:

    <ul class="sub-menu light sidebar-dropdown-menu@(Model.MenuItem == "someMenu"? " open" : "")">
    

    this approach will only open a menu based on the page we are on, it doesn’t really remember what the user clicked on, if it’s very important for you to keep the user selections, you have 2 options,

    • keep sending them back to the server with every request (not very good, too much overhead)
    • keep updating the content using ajax requests and not a full reload of the page, in which case you keep the menu unchanged, and convert all your requests to ajax, and replace the content with the ajax response
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an ASP.NET MVC4 site with mobile content. When I deploy this on
I use ASP.NET MVC4 in my solution. I have the ViewModel below where I
Environment In my solution I have three projects, they are: Web (Asp.net MVC4) Model
Hello everybody i have asp.net mvc4 application where i made countdown something like this:
I have a simple solution with 3 projects: Asp.Net MVC4 Web app - the
I've just created a fresh ASP.NET MVC 4 solution and have added 3 Areas
I have an ASP.NET MVC4 app which uses DotNetOpenAuth 4.0.1 to authenticate users with
I have a simple asp.net MVC4 / EF 4.1 project created with VS 2011,
I have been writing an application using ASP.Net MVC4, where the majority of the
In ASP.NET MVC 4 Beta, I have an entity with this property: [DisplayFormat(DataFormatString =

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.