pop-up menu and source element

2 posts, 0 answers
  1. Joey
    Joey avatar
    32 posts
    Member since:
    Feb 2008

    Posted 02 May 2008 Link to this post

    How do I get the client ID of the element the menu was right clicked on inside of the OnClientItemClicked event handler?

    sender.EventSource doesn't work and DomElement gives me back the object of the menu itself. I need the dom object of the item that was directly under the mouse when the user right clicks to show the pop-up menu.

  2. Peter
    Admin
    Peter avatar
    6637 posts

    Posted 05 May 2008 Link to this post

    Hi Joey,

    Here is an example how to do this:
    <script type="text/javascript">  
    function OnClientItemClickedHandler(sender, eventArgs)  
    {             
        alert(eventArgs.get_targetElement().id);  
    }  
    </script> 
    <telerik:RadContextMenu ID="RadContextMenu1" OnClientItemClicked="OnClientItemClickedHandler" runat="server">  
        <CollapseAnimation Duration="200" Type="OutQuint" /> 
        <Items> 
            <telerik:RadMenuItem runat="server" Text="Root RadMenuItem1">  
            </telerik:RadMenuItem> 
            <telerik:RadMenuItem runat="server" Text="Root RadMenuItem2">  
            </telerik:RadMenuItem> 
        </Items> 
        <Targets> 
            <telerik:ContextMenuControlTarget ControlID="Label1" /> 
            <telerik:ContextMenuControlTarget ControlID="Label2" /> 
        </Targets> 
    </telerik:RadContextMenu> 
    <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label> 
    <asp:Label ID="Label2" runat="server" Text="Label"></asp:Label> 

    Please, try it and let us know if you have further questions.

    Best wishes,
    Peter
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
Back to Top