This is a migrated thread and some comments may be shown as answers.

Change appearance of one menuitem when mouse is over another menuitem OnClientMouseOver

1 Answer 93 Views
Menu
This is a migrated thread and some comments may be shown as answers.
Brenda
Top achievements
Rank 1
Brenda asked on 20 Aug 2008, 10:20 PM
Should I be able to use the following code to set the css class on a menuitem?  I currently set a the css class of the menuitem associated with the current page to rmFocused when they are loaded into the menu.  I am trying to set that menuitem to not appear focused if someone hovers over a different menuitem than set it back after mouse out.

<%

@ Control Language="C#" AutoEventWireup="true" CodeBehind="TopNavigation.ascx.cs" Inherits="EquagenComAdmin.admin.TopNavigation" %>

<%

@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>

<

script language="javascript" type="text/javascript">

function

OnMouseOverItem(menu,args)

{

var item=args.get_item();

var items=menu.get_items();

for(var i=0;i<items.get_count();i++)

{

if(items.getItem(i).get_text() == document.title && items.getItem(i).get_text() != item.get_text())

{

items.getItem(i).set_cssClass(

"");

break;

}

}

}

function

OnMouseOutItem(menu,args)

{

var item=args.get_item();

var items=menu.get_items();

for(var i=0;i<items.get_count();i++)

{

if(items.getItem(i).get_text() == document.title && items.getItem(i).get_text() != item.get_text())

{

items.getItem(i).set_cssClass(

"rmFocused");

break;

}

}

}

</

script>

<

asp:Label ID="MenuResult" runat="server" />

<

telerik:RadMenu ID="TopNavigationMenu" runat="server" Flow="Horizontal" OnClientMouseOver="OnMouseOverItem" OnClientMouseOut="OnMouseOutItem" Width="100%" Skin="EQN" EnableEmbeddedSkins="false">

</

telerik:RadMenu>

1 Answer, 1 is accepted

Sort by
0
Don Johnson
Top achievements
Rank 2
answered on 21 Aug 2008, 05:34 PM
I changed the javascript to the following and it worked.

<

script language="javascript" type="text/javascript">

function OnMouseOverItem(menu,args)

{

var item=args.get_item();

var items=menu.get_items();

for(var i=0;i<items.get_count();i++)

{

var linkElement=items.getItem(i).get_linkElement();

if(items.getItem(i).get_text() == document.title && items.getItem(i).get_text() != item.get_text())

{

linkElement.style.background=

"url(../images/bg_menu.gif) repeat-x";

linkElement.style.color=

"#8b897d";

break;

}

}

}

function OnMouseOutItem(menu,args)

{

var item=args.get_item();

var items=menu.get_items();

for(var i=0;i<items.get_count();i++)

{

var linkElement=items.getItem(i).get_linkElement();

if(items.getItem(i).get_text() == document.title && items.getItem(i).get_text() != item.get_text())

{

linkElement.style.background=

"url(../images/bg_menu-a.gif) repeat-x";

linkElement.style.color=

"#ef3e42";

break;

}

}

}

</

script>

Tags
Menu
Asked by
Brenda
Top achievements
Rank 1
Answers by
Don Johnson
Top achievements
Rank 2
Share this question
or