MOuseOver and MouseOut

3 posts, 1 answers
  1. VS
    VS avatar
    101 posts
    Member since:
    Jul 2008

    Posted 12 Aug 2008 Link to this post

    Hi,

    I am trying to change the backcolor and forecolor on mouseover and mouseout events. But it throws javascript error for LinkElement.
    I had done the same for RadMenu for ASP.Net and its working fine. But this is not working for AJAX Menu.

    The error shown is Item.LinkElement is null or not an object

    Note:- Why am not using css for this is coz i will be knowing the colors only at runtime.

    <script language="javascript" type="text/javascript">
        var oldItemForeColor = "";
        var oldItemBGColor = "";
             
        function clientMouseOver(sender, eventArgs) 
        { 
            var linkElement = eventArgs.Item.LinkElement; 
             
            oldItemForeColor = linkElement.style.color;
            oldItemBGColor = linkElement.style.backgroundColor; 
             
            linkElement.style.color = "<%= MenuBackColor%>";
            linkElement.style.backgroundColor = "<%= MenuForeColor%>";
        } 
         
        function clientMouseOut(sender, eventArgs) 
        {  
            var linkElement = eventArgs.Item.LinkElement; 
             
            linkElement.style.color = oldItemForeColor;
            linkElement.style.backgroundColor = oldItemBGColor;
        }
    </script>

    Please help.

    Thanks & Regards

    Sujith

  2. Answer
    Veselin Vasilev
    Admin
    Veselin Vasilev avatar
    2992 posts

    Posted 12 Aug 2008 Link to this post

    Hello Sujith,

    It seems you are still using the client-side API for the "classic" RadMenu.
    RadMenu for ASP.NET AJAX has different client-side API and you can check these articles on the subject:

    In your case, you need to replace this line:

    var linkElement = eventArgs.Item.LinkElement; 

    with this one:

    var linkElement = eventArgs.get_item().get_linkElement(); 

    I hope this helps.

    Greetings,
    Veskoni
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  3. VS
    VS avatar
    101 posts
    Member since:
    Jul 2008

    Posted 12 Aug 2008 Link to this post

    Hi Veskoni,

    Thanks. Its working now.

    Regards

    Sujith
Back to Top