Menu

Discussion in 'ASP .Net Web Controls' started by Chris Davoli, Jun 18, 2007.

  1. Chris Davoli

    Chris Davoli Guest

    I am tring to get the menu control to do some things, but have had problems
    trying to do what I want to do.

    1.) Why is there underlines under each menu item? How do I get rid of these?
    I've tried to use style sheets but they don't work.
    2.) I want the sub menu items to have a link and when somebody clicks on the
    link to go there, and this works just fine. What I don't want to happen is
    when they click on a parent menu item, I don't want it to do anything other
    than open up the sub menu below it.

    Is there any work arounds? I'm finding the menu hard to use and it should be
    easy.

    Chris
     
    Chris Davoli, Jun 18, 2007
    #1
    1. Advertising

  2. Chris Davoli

    Guest

    On Jun 18, 1:58 pm, Chris Davoli
    <> wrote:
    > I am tring to get the menu control to do some things, but have had problems
    > trying to do what I want to do.
    >
    > 1.) Why is there underlines under each menu item? How do I get rid of these?
    > I've tried to use style sheets but they don't work.
    > 2.) I want the sub menu items to have a link and when somebody clicks on the
    > link to go there, and this works just fine. What I don't want to happen is
    > when they click on a parent menu item, I don't want it to do anything other
    > than open up the sub menu below it.
    >
    > Is there any work arounds? I'm finding the menu hard to use and it should be
    > easy.
    >
    > Chris


    For your first problem, please provide a sample where this is
    occurring for you. I cannot reproduce this. When I create a project
    with just a menu in it, and nothing else, the menu items are not
    underlined because .Net puts styles directly into the page preventing
    that. I have a feeling that you are overriding the style somewhere in
    your code, which is causing the underline.

    For your second problem, this is incredibly easy to do. Every
    MenuItem has a "Selectable" property. You just need to set that for
    your top level items to false. If you are adding menu items in
    your .aspx, it is as simple as this:

    <asp:Menu runat="server" ID="mnuTest">
    <Items>
    <asp:MenuItem NavigateUrl="" Text="Test1" Selectable="False">
    <asp:MenuItem NavigateUrl="test2.html" Text="Test2" />
    <asp:MenuItem NavigateUrl="test3.html" Text="Test3" />
    </asp:MenuItem>
    </Items>
    </asp:Menu>

    If you are using databinding in the code behind, you need to add an
    OnMenuItemDataBound event and then handle setting that property in the
    event handler:
    <asp:Menu runat="server" ID="mnuTest"
    OnMenuItemDataBound="mnuTest_MenuItemDataBound" />

    protected void mnuTest_MenuItemDataBound(object sender, MenuEventArgs
    e)
    {
    if (e.Item.Depth == 0)
    {
    e.Item.Selectable = false;
    }
    }

    I would like to note, however, that it isn't the best usability to
    have a menu where your top level nodes are not clickable. If someone,
    for whatever reason, can't get the scripting to work to get your
    second level to display, then they cannot get anywhere in your site.
     
    , Jun 20, 2007
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Miguel Dias Moura
    Replies:
    3
    Views:
    4,402
    Bruno Sirianni
    Apr 3, 2004
  2. Vilmar
    Replies:
    0
    Views:
    508
    Vilmar
    May 27, 2004
  3. itzikkl
    Replies:
    0
    Views:
    5,850
    itzikkl
    Mar 27, 2005
  4. mike
    Replies:
    2
    Views:
    620
  5. Bryan
    Replies:
    1
    Views:
    812
    Steven Cheng[MSFT]
    Mar 1, 2006
Loading...

Share This Page