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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T02:09:07+00:00 2026-05-13T02:09:07+00:00

In my web app (asp.net C#) I have menus as All, Education, Fun, Comedy.

  • 0

In my web app (asp.net C#) I have menus as “All”, “Education”, “Fun”, “Comedy”. I want when I select All then it should be displayed as current menu, for which I have a CSS class current.

In case of WebUserControls I can do it easily by passing parameter of current page to select as below:

mywebpage.aspx

<uc:header ID="header1" runat="server" selectedMenu="comedy" />

header.ascx (code (c#))

public string selectedMenu
{
    get { return strSelected; }
    set { strSelected = value; }
}

header.ascx (html)

<ul>
   <li><a href="/all/" title="All Videos" <%if (strSelected == "all"){%>class="current"<%} %>><span>All</span></a></li>
   <li><a href="/fun/" title="Fun Videos" <%if (strSelected == "fun"){%>class="current"<%} %>><span>Fun</span></a></li>
   <li><a href="/comedy/" title="Comedy Videos" <%if (strSelected == "comedy"){%>class="current"<%} %>><span>Comedy</span></a></li>
</ul>

When I’ll pass comedy from my webpage to usercontrol then it will select comedy menu. I want to implement the same kind of functionality in case of master pages, could anyone tell me how to achieve this type of facility for master pages.

One way what I feel is to pass a query string parameter http://example.com/all/?select=all, I’ll check on master page_load function if select parameter is “all” or fun or comedy then select corresponding menu. But this is not good, because I don’t want to add an extra query string parameter to my URLs.

Please tell me how to solve this issue.

Thanks

  • 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-13T02:09:07+00:00Added an answer on May 13, 2026 at 2:09 am

    You can access master page properties from your content page after casting the master to the correct type:

    public class MyMasterPage : MasterPage
    {
        public string MyMenuProperty { get; set; }
    
        protected void Page_PreRender(object sender, EventArgs e)
        {
            if (MyMenuProperty == "comedy")
            {
                /* do your menu stuff */
            }
        }
    }
    
    public class MyContentPage : Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            var myMaster = Page.Master as MyMasterPage;
            if (myMaster != null)
            {
                myMaster.MyMenuProperty = "comedy";
            }
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Have an ASP.net web app which works fine for a few days, but then
I have an asp.net web app. I want to separate out a particular section
i have a web app in asp.net running on windows authentication i want only
The thing I have a web app (asp.net) which needs to have a feed.
I have a simple web app built in asp.net webforms c# where and how
I have a Silverlight web app which uses ASP.net Website administration tool for user
I have a asp.net/c# web app. When do user leave a certain page, I
I have an ASP.NET(2.0 using C#) web app, in which I have a gridview.
I have a SQL query in my ASP.net web app that looks like this:
Im trying to develop my first ASP.NET MVC web app and have run into

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.