open menu item on page load

4 posts, 0 answers
  1. Matthias
    Matthias avatar
    3 posts
    Member since:
    Nov 2008

    Posted 10 Nov 2008 Link to this post

    Can I use a javascript to open a menu item on page load? <body onload="OpenItem()">?

    Thanks,

    Matt
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 10 Nov 2008 Link to this post

    Hi Matthias,

    You can add "OnClientLoad" to RadMenu in order to call the JavaScript function for opening the RadMenu items.

    JavaScript

    function OpenItem() 
     var menu = $find("<%= RadMenu1.ClientID %>"); 
     var item = menu.findItemByText("File"); 
     item.open(); 


    Regards,
    Shinu.
  3. Matthias
    Matthias avatar
    3 posts
    Member since:
    Nov 2008

    Posted 11 Nov 2008 Link to this post

    Hi Shinu,

    Thanks for your quick reply. I have tried your script, but I'm getting a javascript error: "null is null or no object"

    <script type="text/javascript">  
    //<!--  
     
    function OpenItem() {  
     var menu = $find("<%= RadMenu1.ClientID %>");  
     var item = menu.findItemByText("Nachrichten");  
    }  
     
    //--> 
    </script> 
     
    <telerik:RadMenu ID="RadMenu1" runat="server" Style="top: 0px; left: 0px" Width="820px" 
         OnClientLoad="OpenItem()"

    Regards,

    Matthias
  4. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 11 Nov 2008 Link to this post

    Hi Matthias,

    Try modifying the OnClientLoad method as OnClientLoad="OpenItem" (without brackets) in RadMenu declaration.

    ASPX:
    <telerik:RadMenu ID="RadMenu1" runat="server" Style="top: 0px; left: 0px" Width="820px" OnClientLoad="OpenItem">  
     
    function OpenItem()   
    {   
     var menu = $find("<%= RadMenu1.ClientID %>");   
     var item = menu.findItemByText("Nachrichten");   
     item.open();   
    }


    Thanks,
    Princy.
Back to Top