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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T11:46:42+00:00 2026-05-27T11:46:42+00:00

I apologize that I’m still extremely new to MVC so please bear with me.

  • 0

I apologize that I’m still extremely new to MVC so please bear with me.

I’m trying to create a dynamic list element for navigation in the _Layout.cshtml.
I’m not really too sure where to go from here. Or where to put my database code. Thanks.

    <ul id="navlist">
    @foreach (???)
        {<li class="navitem"><a href="@nav.Href">@nav.Name</a></li>}
    </ul>
  • 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-27T11:46:43+00:00Added an answer on May 27, 2026 at 11:46 am

    Go through a tutorial which builds an application from start to finish using mvc. It will be much better than asking this type of question. Plus you will learn a lot more. But in helping out here is what you do

    MVC Controller – Home Controller

    public class HomeController : Controller
    {
       public ActionResult Index()
       {
        var viewModel = new IndexViewModel();
        viewModel.NavItems = // Get your data and assign it here.
    
        return View(viewModel);
    
        }
    }
    
    public class IndexViewModel
    {
       public List<NavItem> NavItems {get; set;}
    }
    
    public class NavItem
    {
        public string Href {get; set;}
        public string Name {get; set;
    }
    

    Razor View

    @model IndexViewModel
    
    <ul>
    @foreach(var item in Model.NavItems)
    {
      <li class="navitem"><a href="@item.Href">@item.Name</a></li>
    }
    </ul>
    

    You can see here all of the basic parts in MVC. We have a Controller which builds a Model and passes it to a View. M V C. The 3 is for the version lol 🙂

    Again this is super basic. I would suggest http://www.asp.net/mvc, tekpub.com, for getting a better foundation

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

Sidebar

Related Questions

Please keep in mind that I'm new to C# and OOP so I apologize
I am new to android development, I apologize that similar questions has been asked
Programming is so new to me that I apologize for not knowing how to
I apologize, I am new to this and assume that I will mix some
This post will be lengthy and I apologize on beforehand for that. I'm trying
My question consists of multiple points that are inherently related, I apologize for that.
I'm a newer and if the question is so easy I apologize for that.
Alright, I am hoping someone can help me out. I apologize up front that
I apologize for this seemingly relatively simple task that I can't figure out. I
I apologize if this is a duplicate. I am writing a class that needs

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.