Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Sub menu - How to write click event?

Sub menu - How to write click event?

Scheduled Pinned Locked Moved ASP.NET
csharpsysadminhelptutorialquestion
7 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    Paulraj G
    wrote on last edited by
    #1

    Hi... I am having a main menu called menu1. Its sub menus are submenu1, submenu2,submenu3. I can write event for main menu click event as ASP code:

    <asp:Menu ID="Menu1" runat="server" Orientation="Horizontal" ForeColor="white" BorderStyle="None"
    Height="30px" onmenuitemclick="Menu1_MenuItemClick">

    and c# code is:

    protected void Menu1_MenuItemClick(object sender, MenuEventArgs e)
    {
    Str = "sample";
    }

    Now how to write click event for submenu1? any help will be appriciated.... thanks...

    G.Paulraj

    S A 2 Replies Last reply
    0
    • P Paulraj G

      Hi... I am having a main menu called menu1. Its sub menus are submenu1, submenu2,submenu3. I can write event for main menu click event as ASP code:

      <asp:Menu ID="Menu1" runat="server" Orientation="Horizontal" ForeColor="white" BorderStyle="None"
      Height="30px" onmenuitemclick="Menu1_MenuItemClick">

      and c# code is:

      protected void Menu1_MenuItemClick(object sender, MenuEventArgs e)
      {
      Str = "sample";
      }

      Now how to write click event for submenu1? any help will be appriciated.... thanks...

      G.Paulraj

      S Offline
      S Offline
      sashidhar
      wrote on last edited by
      #2

      Try this link it may help..! http://msdn.microsoft.com/en-us/magazine/cc163848.aspx[^]

      LatestArticle :Log4Net Why Do Some People Forget To Mark as Answer .If It Helps.

      1 Reply Last reply
      0
      • P Paulraj G

        Hi... I am having a main menu called menu1. Its sub menus are submenu1, submenu2,submenu3. I can write event for main menu click event as ASP code:

        <asp:Menu ID="Menu1" runat="server" Orientation="Horizontal" ForeColor="white" BorderStyle="None"
        Height="30px" onmenuitemclick="Menu1_MenuItemClick">

        and c# code is:

        protected void Menu1_MenuItemClick(object sender, MenuEventArgs e)
        {
        Str = "sample";
        }

        Now how to write click event for submenu1? any help will be appriciated.... thanks...

        G.Paulraj

        A Offline
        A Offline
        Abhijit Jana
        wrote on last edited by
        #3

        Where is your menu SubItems ? You need to first create the menu subitems inside "Items" tag. Then you can use the same event handler for all the items. Have a look into this article, http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.menu.menuitemclick%28VS.80%29.aspx[^] Please let me know if you need any more information. Thanks

        P 1 Reply Last reply
        0
        • A Abhijit Jana

          Where is your menu SubItems ? You need to first create the menu subitems inside "Items" tag. Then you can use the same event handler for all the items. Have a look into this article, http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.menu.menuitemclick%28VS.80%29.aspx[^] Please let me know if you need any more information. Thanks

          P Offline
          P Offline
          Paulraj G
          wrote on last edited by
          #4

          Hi Abhijith, Thanks for your reply... My code is as follows. Please tell me how to create menu subitem on this...

          <asp:Menu ID="Menu1" runat="server" Orientation="Horizontal" ForeColor="white" BorderStyle="None"
          Height="30px" onmenuitemclick="Menu1_MenuItemClick">
          <DynamicHoverStyle ForeColor="#000000" BackColor="Black"/>
          <Items>

                          <asp:MenuItem Text="File" Value="File">
                              <asp:MenuItem Text="Open" Value="Open" ToolTip="Open File"></asp:MenuItem>
                              <asp:MenuItem Text="Recent Files" Value="Recent"></asp:MenuItem>
                              <asp:MenuItem Text="Exit" Value="Exit"></asp:MenuItem>
                          </asp:MenuItem>
          

          Thanks....

          G.Paulraj

          A 1 Reply Last reply
          0
          • P Paulraj G

            Hi Abhijith, Thanks for your reply... My code is as follows. Please tell me how to create menu subitem on this...

            <asp:Menu ID="Menu1" runat="server" Orientation="Horizontal" ForeColor="white" BorderStyle="None"
            Height="30px" onmenuitemclick="Menu1_MenuItemClick">
            <DynamicHoverStyle ForeColor="#000000" BackColor="Black"/>
            <Items>

                            <asp:MenuItem Text="File" Value="File">
                                <asp:MenuItem Text="Open" Value="Open" ToolTip="Open File"></asp:MenuItem>
                                <asp:MenuItem Text="Recent Files" Value="Recent"></asp:MenuItem>
                                <asp:MenuItem Text="Exit" Value="Exit"></asp:MenuItem>
                            </asp:MenuItem>
            

            Thanks....

            G.Paulraj

            A Offline
            A Offline
            Abhijit Jana
            wrote on last edited by
            #5

            You need to close tag and tag First. Try This :

            And In Code Behind :

            protected void Menu1_MenuItemClick(object sender, MenuEventArgs e)
            {
            Response.Write(e.Item.Text);
            }

            Here you will find on click of every menu items / subitems , Menu Text getting write on page. Hope this will help you !

            P 1 Reply Last reply
            0
            • A Abhijit Jana

              You need to close tag and tag First. Try This :

              And In Code Behind :

              protected void Menu1_MenuItemClick(object sender, MenuEventArgs e)
              {
              Response.Write(e.Item.Text);
              }

              Here you will find on click of every menu items / subitems , Menu Text getting write on page. Hope this will help you !

              P Offline
              P Offline
              Paulraj G
              wrote on last edited by
              #6

              Ya... Its working fine... Thanks...

              G.Paulraj

              A 1 Reply Last reply
              0
              • P Paulraj G

                Ya... Its working fine... Thanks...

                G.Paulraj

                A Offline
                A Offline
                Abhijit Jana
                wrote on last edited by
                #7

                Welcome :)

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups