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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T18:42:10+00:00 2026-05-24T18:42:10+00:00

i am writing new asp.net mvc application and i have question about creating multi-level

  • 0

i am writing new asp.net mvc application and i have question about creating multi-level navigation system.

For example i have web with main navigation (Cpu — Gpu —- Ram)

and sub-navigation with (intel,amd — ati,nvidia — DDR2,DD3)

Well, my first implementation is here :

public class NavigationItem
{
    public virtual int Id { get; set; }
    public virtual string Title { get; set; }
    public virtual string Controller { get; set; }
    public virtual string Action { get; set; }
    public virtual string Url { get; set; }
    public virtual string Section { get; set; }
}


public class NavigationController : Controller
{
    private readonly IUnitOfWork _unitOfWork;

    public NavigationController(IUnitOfWork unitOfWork)
    {
        _unitOfWork = unitOfWork;
    }

    public ActionResult MainMenu()
    {
        return View(_unitOfWork.NavigationItems.Where(x => x.Section == null).ToList());
    }

    public ActionResult SectionMenu()
    {


        return View(_unitOfWork.NavigationItems.Where(x => x.Section == "// name of section").ToLis());
    }
}

And finally my layout page is :

<!DOCTYPE html>
<html>
<head>
    <title>@ViewBag.Title</title>
</head>
<body>
 <div class="main-menu">
  @{Html.RenderAction("MainMenu", "Navigation");}
 </div>

 <div class="section-menu">
  @{Html.RenderAction("SectionMenu", "Navigation");}
 </div>

    @RenderBody()
</body>
</html>

With this implementation i have problem how i handle in SectionMenu with MainMenu is active, because i want generate SectionMenu depends on MainMenu and highlight them.

One workaround of witch i think is handle url(controller) in SectionMenu.
For example :

    if (RouteData.Values["controller"].ToString() == "Administration")
    {
        // Generate section menu for Administration main menu
    }

I dont like this solution because i work with “magic string” values and i havent only one controller per one MainMenu.

How implement this solution?

Thanks for advice

  • 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-24T18:42:11+00:00Added an answer on May 24, 2026 at 6:42 pm

    Ok, I use ViewBag feature. Not clean, but works

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

Sidebar

Related Questions

I'm writing a new asp.net mvc application and I've been toying with the idea
I'm writing a new application in ASP.NET MVC. I've created a custom MembershipProvider that
Newbie question. I’m writing an ASP.Net MVC app in VB.Net and have been using
Have just started converting an existing job tracking system into an ASP.NET MVC application.
I am writing an ASP.NET MVC 2.0 application which requires users to log in
I am writing an asp.net MVC app that drives an IPhone application. I want
I am writing an application in asp.NET, I use the MVC 3 model(views engine
I am writing unit tests against my ASP.NET MVC application, in particular I am
ASP.NET MVC noob here I was writing a quiz application where a user can
My team is writing a content-managed web-hosting application in ASP.Net MVC 2 with the

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.