accmats
asked on
Help with Menu Control in ASP.net
I have created a menu control for site navagation on my web page. I have given it a width of 150px. I also applied an Auto Format so it would have mouse over functions, etc. The problem is that you have to click on the Menu Item Text for your hyperlink to work. Becuase my menu has a width of 150px, I have empty space to the right of most of my link descriptions. But when you roll the mouse the select menu item background changes as it should. But if you don't mouse click on the text, then the menu doesn't work.
How can I insure that the link will work if they click anywhere within the menu item region?
Thanks!!!
How can I insure that the link will work if they click anywhere within the menu item region?
Thanks!!!
Actually, it's working on my system without all the javascript stuff in the client-side onclick handler. So it looks like the javascript stuff is unnecessary.
<asp:Menu ID="mnu" runat="server" Orientation="horizontal">
<StaticItemTemplate>
<div
style="width:150px;">
<asp:HyperLink
ID="lnk"
runat="server"
Text='<%# Eval("Text") %>'
NavigateUrl='<%# Eval("NavigateUrl") %>' />
</div>
</StaticItemTemplate>
<DynamicItemTemplate>
<div
style="width:150px;">
<asp:HyperLink
ID="lnk"
runat="server"
Text='<%# Eval("Text") %>'
NavigateUrl='<%# Eval("NavigateUrl") %>' />
</div>
</DynamicItemTemplate>
</asp:Menu>
<asp:Menu ID="mnu" runat="server" Orientation="horizontal">
<StaticItemTemplate>
<div
style="width:150px;">
<asp:HyperLink
ID="lnk"
runat="server"
Text='<%# Eval("Text") %>'
NavigateUrl='<%# Eval("NavigateUrl") %>' />
</div>
</StaticItemTemplate>
<DynamicItemTemplate>
<div
style="width:150px;">
<asp:HyperLink
ID="lnk"
runat="server"
Text='<%# Eval("Text") %>'
NavigateUrl='<%# Eval("NavigateUrl") %>' />
</div>
</DynamicItemTemplate>
</asp:Menu>
ASKER
Thanks for your reply. That worked but is there a way to keep the text from looking like a hyperlink and taking on hyperlink type styles like being underlined and hyperlinked font color?
Thanks for all your help!
Thanks for all your help!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Awsome answer. Thanks for all your help. I have added an additional question that is related to this one if you think you might can answer it. THANKS AGAIN!
https://www.experts-exchange.com/questions/21895574/How-to-keep-static-menu-item-highlighted-when-dynamic-menu-appears-in-ASP-net-2-0.html
https://www.experts-exchange.com/questions/21895574/How-to-keep-static-menu-item-highlighted-when-dynamic-menu-appears-in-ASP-net-2-0.html
<asp:Menu ID="mnu" runat="server" Orientation="horizontal">
<StaticItemTemplate>
<div
onclick="window.navigate('
<asp:HyperLink
ID="lnk"
runat="server"
Text='<%# Eval("Text") %>'
NavigateUrl='<%# Eval("NavigateUrl") %>' />
</div>
</StaticItemTemplate>
<DynamicItemTemplate>
<div
onclick="window.navigate('
<asp:HyperLink
ID="lnk"
runat="server"
Text='<%# Eval("Text") %>'
NavigateUrl='<%# Eval("NavigateUrl") %>' />
</div>
</DynamicItemTemplate>
</asp:Menu>