?
Solved

disable onmouseover from menu in asp.net

Posted on 2011-10-16
1
Medium Priority
?
1,819 Views
Last Modified: 2012-05-12
i have this menu:

                <asp:Menu ID="Menu1" runat="server" BackColor="#FFFBD6"
                    DynamicHorizontalOffset="2" Font-Names="Verdana" Font-Size="0.8em"
                    ForeColor="#990000" StaticSubMenuIndent="10px" Width="248px">
                    <DynamicHoverStyle BackColor="#990000" ForeColor="White" />
                    <DynamicMenuItemStyle HorizontalPadding="5px" VerticalPadding="2px" />
                    <DynamicMenuStyle BackColor="#FFFBD6" />
                    <DynamicSelectedStyle BackColor="#FFCC66" />
                    <Items>
                        <asp:MenuItem Text="    menu0" Value="0"   </asp:MenuItem>
                        <asp:MenuItem Enabled="False" Value="" Selectable="False" Text="<br/>Section1<br/><hr noshade/>"></asp:MenuItem>
                        <asp:MenuItem  Text="    menu1" Value="1"></asp:MenuItem>
                        <asp:MenuItem  Text="    menu2" Value="2"></asp:MenuItem>
                        <asp:MenuItem  Text="    menu3" Value="3></asp:MenuItem>
                    </Items>
                    <StaticHoverStyle BackColor="#990000" ForeColor="White" />
                    <StaticMenuItemStyle HorizontalPadding="5px" VerticalPadding="4px"
                        Width="240px" />
                    <StaticSelectedStyle BackColor="#FFCC66" />
                </asp:Menu>

now, on the Section1, i don't want the onmouseover event to be fire, so the menu don't change the color of the div, or show any change. only on the others menus.

any idea?
0
Comment
Question by:rafaelrgl
1 Comment
 
LVL 83

Accepted Solution

by:
leakim971 earned 2000 total points
ID: 36976714
put this in the head section :
<script language="javascript" type="text/javascript">
    window.onload = function () {
        document.getElementById("<%= Menu1.ClientID %>").getElementsByTagName("a")[0].onmouseover = function (e) {
  	    if (!e) var e = window.event;
	    e.cancelBubble = true;
	    if (e.stopPropagation) e.stopPropagation();
        }
    }
</script>

Open in new window


with jQuery :

<script language="javascript" type="text/javascript" src="http://code.jquery.com/jquery-1.6.4.js"></script>
<script language="javascript" type="text/javascript">
        $(document).ready(function () {
            $("a:eq(0)", "#<%= Menu1.ClientID %>").mouseover(function (e) {
                e.stopPropagation();
            })
        })
</script>

Open in new window

0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…
Suggested Courses
Course of the Month13 days, 9 hours left to enroll

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question