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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T08:42:43+00:00 2026-06-13T08:42:43+00:00

On a post back i cannot seem to get the selected menu item from

  • 0

On a post back i cannot seem to get the selected menu item from the menu control in the MasterPage. I tried the following in page_load but it does not work and errors out ‘Object reference not set to an instance of an object’.

Html in the MasterPage

<asp:Menu ID="NavigationMenu" runat="server" CssClass="menu" EnableViewState="false"
       IncludeStyleBlock="false" Orientation="Horizontal">
       <Items>
            <asp:MenuItem NavigateUrl="~/Default.aspx" Text="Home" />
           <asp:MenuItem NavigateUrl="~/About.aspx" Text="About" />
            <asp:MenuItem NavigateUrl="~/Contact.aspx" Text="Contact" />
       </Items>
</asp:Menu>

Page_Load in the MasterPage

 If IsPostBack Then
   Select Case NavigationMenu.SelectedItem.Text
        Case "Home"
            'code
        Case "About"
            'code
        Case "Contact"
            'code
   End Select
End If
  • 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-13T08:42:44+00:00Added an answer on June 13, 2026 at 8:42 am

    You can use the MenuItemClick event. If NavigateUrl property is null “”, then the click event fires, if you have either “#” or a url to another page then the click event does not work. Reference article

      Protected Sub NavigationMenu_MenuItemClick(sender As Object, e As System.Web.UI.WebControls.MenuEventArgs) Handles NavigationMenu.MenuItemClick
        Select Case e.Item.Text
            Case "Home"
                'code
            Case "About"
                'code
            Case "Contact"
                'code
        End Select
      End Sub
    

    Event will fire…

    <asp:MenuItem NavigateUrl="" Text="Home" />
    

    Event will not fire…

    <asp:MenuItem NavigateUrl="~/About.aspx" Text="About" />
    

    Note:
    I ended up using an Unordered List instead with Javascript postback to server side events. The asp.net MenuControl was not flexible enough for my situation.

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

Sidebar

Related Questions

How to get the control or control Id which caused the post back in
I have tried just about everything at this point, but I cannot get a
How do I force full post-back from a button within an UpdatePanel?
I need to open a new window from code-behind on post-back if a specific
Although probarly quite simple, i cannot seem to find the following. The form takes
I am aware of this other post , but it doesn't seem to apply
this is a post back problem (I don't want to use the client side
Looking at an older stackoverflow post (back in June 2009, Is the WCF REST
basically my aim is to use JQuery to post back an x & y
I am puzzled why this return false doesn't cancel the post-back. function validate() {

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.