locked
Menu Control in Master Pages RRS feed

  • Question

  • User-465541547 posted

    I have a menu control placed in Master Page. On click of different menus i am not redirecting to different pages instead i have only one page. But on click of different menu items i want to show different labels/things on same page. 

    I dont know how and where to check which menu item is currently clicked. I am trying it on page_load of content page  but not able to detect there. Following is the code snippet. Here  CUTMaster is Master page. I have created a property on master page which returns the menu placed over the master page. I am accessing the menu control placed over master page on the content page_load event. as follow:

    CUTMaster objCUTMaster = new CUTMaster();

    Menu mnu = objCUTMaster.MasterMenuControl;

    if (mnu.Items[1].Selected)

    {

    imgRevert.ImageUrl =
    "~/Images/Revert.jpg";

    }

    Monday, March 10, 2008 2:32 AM

Answers

  • User-1675550968 posted

    hi!

    use MenuItemClick event.

    In page load add event handler to menu control:


     CUTMaster objCUTMaster = new CUTMaster();

    Menu mnu = objCUTMaster.MasterMenuControl;

    mnu.MenuItemClick += new MenuEventHandler(MainMenu_MenuItemClick);
       

    then in event handler do what you need:

        void MainMenu_MenuItemClick(object sender, MenuEventArgs e)
        {
            e.Item.Text = "Clicked";
        }

     

    hope it helps

    orzeh 

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, March 10, 2008 3:56 AM