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

  • Home
  • SEARCH
  • 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 6606051
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T19:21:17+00:00 2026-05-25T19:21:17+00:00

For my website project I am using ASP.NET MVC Razor. Learning as I go.

  • 0

For my website project I am using ASP.NET MVC “Razor”. Learning as I go.

I have 5 or 6 pages on my site, and one page that is on another site. I want users to feel like they are using the same site for all.

There is a typical HTML menu for the pages which follows the standard pattern of using a XHTML unordered list and CSS to layout:

<ul id="menu">
    <li class="selected"><a href="@Href("~/")">Home</a></li>
    <li><a href="http://ceklog.kindel.com">cek.log</a></li>
    <li><a href="@Href("~/Services")">Services</a></li>
    <li><a href="@Href("~/Charlie")">Charlie's Stuff</a></li>
    <li><a href="@Href("~/Contact.cshtml")">Contact</a></li>
</ul>

Elsewhere on SO I found questions similar to mine, where people wanted to track the selected menu item, but within a dynamic page. For example:

Javascript Changing the selected Menu items class

But this approach won’t work in my case because in my case the user is not changing a selection on one page, but navigating to another page completely.

How can this be done?

  • 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-25T19:21:18+00:00Added an answer on May 25, 2026 at 7:21 pm

    …and I figured it out.

    I used Razor to implement this on the server side.

    First I implemented a function on my _SiteLayout.cshtml page (the template all pages use):

    @functions {
        public string Selected(string PageTitle) {
           if (Page.Title == PageTitle)
              return "selected";
            else
              return "";
        }
    }
    

    Then I used this function in my list:

    <ul id="menu">
        <li class="@Selected("Home")"><a href="@Href("~/")">Home</a></li>
        <li class="@Selected("cek.log")"><a href="http://ceklog.kindel.com">cek.log</a></li>
        <li class="@Selected("Services")"><a href="@Href("~/Services")">Services</a></li>
        <li class="@Selected("Charlie's Stuff")"><a href="@Href("~/Charlie")">Charlie's Stuff</a></li>
        <li class="@Selected("Contact")"><a href="@Href("~/Contact.cshtml")">Contact</a></li>
    </ul>
    

    Works perfectly. On my external page, I just hand-coded it since it’s based on WordPress and not Razor.

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

Sidebar

Related Questions

I have a website project that I want to build using CruiseControl.net. On one
I have built an ASP.NET MVC 3 web application (with exlusively Razor/cshtml pages) that
I am working with asp.net website project that some of pages need authentication. I
I have an existing complex website built using ASP.NET MVC, including a database backend,
I have been using telerik extensions for an asp.net mvc project, more specifically the
In my current project, we have to create a website (ASP.NET MVC) which is
I have created a new ASP.NET MVC project using the MVC Project Template. According
I'm working on a Web project using Asp.Net MVC, which I'll have to deploy
I have a project using Asp.Net 3.5 and MVC 1. Everything runs perfectly on
I have a Website project that I'm trying to debug using Fiddler. Fiddler doesn't

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.