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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T09:21:39+00:00 2026-06-17T09:21:39+00:00

In my asp.net web application, i have created a menu and menuItem programatically based

  • 0

In my asp.net web application, i have created a menu and menuItem programatically based on the Logged in user role.The Code is given below…

    Menu menu = new Menu();
    menu.CssClass = "menu";
    menu.IncludeStyleBlock = false;
    menu.EnableViewState = false;
    menu.Orientation = Orientation.Horizontal;

    if (roleType.equals("teacher"))
    {
        MenuItem categoryItemCh1 = new MenuItem("Home");
        categoryItemCh1.NavigateUrl = "Teacher/TestsList.aspx";
        menu.Items.Add(categoryItemCh1);

        MenuItem categoryItemCh2 = new MenuItem("Account");
        categoryItemCh2.NavigateUrl = "Account/underconstruction.aspx";
        menu.Items.Add(categoryItemCh2);

        MenuItem categoryItemCh3 = new MenuItem("Reports");
        categoryItemCh3.NavigateUrl = "Account/underconstruction.aspx";
        menu.Items.Add(categoryItemCh3);

        MenuItem categoryItemCh4 = new MenuItem("Logout");
        menu.Items.Add(categoryItemCh4);
    }

So, When user clicks the logout menu item , then i have to fire menuItem click event to do the following process.

1.Clear all the session associated with the user
2.Redirect to Login page.

But i don’t know how to add a menuItem click event programatically in asp.net.Please guide me to get out of this issue…

  • 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-17T09:21:40+00:00Added an answer on June 17, 2026 at 9:21 am

    Use the MenuItemClick event. You don’t add an event to each menu item but to the menu itself

    menu.OnMenuItemClick += Menu_MenuItemClick;
    
    
    void Menu_MenuItemClick(Object sender, MenuEventArgs e)
    {
    // Display the text of the menu item selected by the user.
    Message.Text = "You selected " + 
      e.Item.Text + ".";
    }
    

    You can use the MenuEventArgs to figure out which menu item was clicked

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

Sidebar

Related Questions

I have created an ASP.NET Webforms web application which basically inetracts with the code
I have created a Visual Studio 2010 ASP.NET Web Application. With it I have
I have created a Visual Studio 2010 ASP.NET Web Application. I've noticed that if
I have the following scenario. I have created an ASP.NET web application (framework 3.5)
I have created blank Asp.Net-MVC 3 web application and want to write my own
I have a web application in Asp.Net. I've created my master page and inside
I have already created my application on web socket with ASP.net 4.0. I just
Hi i have created the asp.net web application without considering the time zone. I
I have Web Application in asp.net. Where I am maintaining Session for every User.
i have created one web application in asp.net[.net 4 framework and visual studio 2010].Now

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.