Menu

C

Chris Davoli

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
 
C

charles.boyung

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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,818
Latest member
Brigette36

Latest Threads

Top