Opening context menu on radbutton left click

5 posts, 0 answers
  1. USI
    USI avatar
    26 posts
    Member since:
    Oct 2009

    Posted 24 Jan 2012 Link to this post


    Is it possible to open a RadContextMenu on RadButton left click only? I was only able to open the context menu with right click but not with left click.

    Thanks in advance,
    Michael Pinheiro
  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 24 Jan 2012 Link to this post


    Try the following javascript on OnClientClicked event of RadButton.
    function OnClientClicked(sender, args)
        var contextMenu = $find("<%= RadMenu1.ClientID %>");;

  3. Shukhrat Nekbaev
    Shukhrat Nekbaev avatar
    73 posts
    Member since:
    Oct 2010

    Posted 01 Mar 2012 Link to this post

    <telerik:RadButton ID="btnAddComponent" runat="server" Text="Show items" AutoPostBack="false" OnClientClicked="addNewComponent" UseSubmitBehavior="false">
    <span onclick="javascript:showMenu(event);">Test open</span>

    and menu:
    <telerik:RadContextMenu ID="radCtxMenuNewPageComponent" runat="server" CausesValidation="true" ValidationGroup="editCurrentProjectContentElement" OnItemClick="radCtxMenuNewPageComponent_ItemClick">
            <telerik:RadMenuItem Text="Audio" />
            <telerik:RadMenuItem Text="Video" />
        <CollapseAnimation Type="none" />

    following JS:

    function addNewComponent(sender, args) {
    function showMenu(e) {
        var contextMenu = $find("<%= radCtxMenuNewPageComponent.ClientID %>");
        if ((!e.relatedTarget) || (!$telerik.isDescendantOrSelf(contextMenu.get_element(), e.relatedTarget))) {

    so when RadButton is clicked it works in IE9 and latest Chrome (haven't tried anything else yet), but doesn't work in FF, in FF it complains on event object. In RadButton's click handler I tried to pass "args" also, then in IE9 context menu is displayed in top left corner, but doesn't work in FF. Provided span trigger works good.

    How do I get RadButton to trigger context menu so that it works in all browsers? Thank you!

    P.S.: using latest controls (2012.1.215.40)
  4. Peter
    Peter avatar
    6637 posts

    Posted 06 Mar 2012 Link to this post


    The DOM event on clicking the RadButton is not passed to the event argument. Therefore, you cannot use this approach with RadButton. As a workaround, you can try the following:
    function addNewComponent(sender, args) {
                    var currentLocation = $telerik.getLocation(sender.get_element());
                    var contextMenu = $find("<%=radCtxMenuNewPageComponent.ClientID%>");
                    contextMenu.showAt(currentLocation.x, currentLocation.y + 22);  

    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
  5. Shukhrat Nekbaev
    Shukhrat Nekbaev avatar
    73 posts
    Member since:
    Oct 2010

    Posted 06 Mar 2012 Link to this post


    yeah, I've implemented similar workaround already, thanks anyway!
Back to Top