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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T03:17:42+00:00 2026-06-06T03:17:42+00:00

Scenario: Every page on the website will have a menu bar at the top

  • 0

Scenario: Every page on the website will have a menu bar at the top consisting of a number of buttons. Some pages have the same amount of button that do the same thing (example redirect to a page) but some of the buttons depend on information currently on the page.
Problem: I would like to be able to override the buttons on the control so that I could handle it per page. I was also thinking maybe it would be easier to use events and handle it that way instead. Are either of these approaches possible and if not is there an alternative?

The code I currently have is below

In the aspx page

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
    If Not Page.IsPostBack Then
        Dim myMenu As MenuBar
        myMenu = CType(Master.FindControl("MenuBar1"), MenuBar)
        myMenu.ShowButtons(MenuBar.Buttons.NewOrganization, MenuBar.Buttons.NewEquipment, MenuBar.Buttons.ChangeEquipmentOwner, MenuBar.Buttons.ChangeEquipmentLocation)

    End If
End Sub

The ascx Control

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
    If Not Page.IsPostBack Then
        RaiseEvent myEvent(sender, e)
    End If
End Sub
Public Sub ShowButtons(ByVal ParamArray args() As Buttons)
    For i As Integer = 0 To args.GetUpperBound(0)
        SetVisible(args(i))
    Next
End Sub
Public Enum Buttons
    NewOrganization = 1
    NewEquipment = 2
    ChangeEquipmentOwner = 3
    ChangeEquipmentLocation = 4
    UnderDevelopment = 5
    CheckoutEquipment = 6
    EditDocument = 7
    CreateEquipmentLoanForm = 8
End Enum
Private Sub SetVisible(ByVal btn As Buttons)
    Select Case (btn)
        Case 1
            btnNewOrganization.Visible = True
        Case 2
            btnNewEquipment.Visible = True
        Case 3
            btnChangeOwner.Visible = True
        Case 4
            btnChangeLocation.Visible = True
        Case 5
            btnUnderDevelopment.Visible = True
        Case 6
            btnCheckoutEquipment.Visible = True
        Case 7
            btnEditDocument.Visible = True
        Case 8
            btnCreateEquipment.Visible = True
    End Select
End Sub
  • 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-06T03:17:43+00:00Added an answer on June 6, 2026 at 3:17 am

    What I would do is to use a content place holder on your master page that will be reserved for things like your menu control. Each page could then provide the menu control.

    Using this technique will enable each of your pages to tailor the control to the desired effect without coupling masterpage/page logic. Not only that, but each page wouldn’t be married to the 1 control that you use on the master page. You may at some point want to include another menu control or a completely different menu control without affecting any of the other pages.

    BUT
    If you absolutely must interact with your master page from your content page and you aren’t receptive of my ideas, you can do this for example using C# (but can easily be adapted to VB.NET in your case):

    Masterpage CodeBehind

    Be sure to add a method in your masterpage codebehind..something like so:

    public void updateMenuControlWithOptions(MenuOptions options)
    {
         //Tailor your menu control based on provided options
         //Menu1.FooButton.Visible = options.FooButtonVisible;
    }
    

    ASPX

    Be sure to add the following directive to a page. You’ll see why this is helpful in a bit, also change my masterpage name to yours:

    <%@ MasterType VirtualPath="~/Main.Master" %>
    

    ASPX CodeBehind

    if (foo)
        whateverOptions.FooButtonVisible = true;
    
    this.Master.updateMenuControlWithOptions(whateverOptions);
    

    Observe that I didn’t have to type cast the master..this is because of the MasterType directive I included in the aspx.

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

Sidebar

Related Questions

I have a scenario whereby with every page request I must check the session
Here's my scenario: I'm using JSF. I have a page that refreshes every 5
Scenario: Say I am on an invoice details page. I have a customer name
I have some static websites. By static I mean all the pages are simple
The scenario Let's say I have a sidebar where every box / widget is
Here's the simplified scenario: I have a page with two sections: a search section,
First to describe my scenario. On my page I have div with id showImage.
I am facing a strange scenario. basically on my every web page i am
Let's say you have this scenario:a simple blog home-page that loads both static content
I have about 100 pages, every of which has 10-100 images attached. The path

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.