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

Make RadContextMenu ignore input controls

2 Answers 30 Views
Menu
This is a migrated thread and some comments may be shown as answers.
Sam
Top achievements
Rank 1
Sam asked on 14 Oct 2013, 04:48 PM
Hi,

I'm using RadContextMenu with the ContextMenuDocumentTarget and it works great because I can right click anywhere on the page to bring up the context menu.

However, is there an easy way I can keep using ContextMenuDocumentTarget but have it disabled on input controls like textboxes and text areas?

Basically, I want the default browser context menu to show up when right-clicking inside input controls, but every where else on the page, for the RadContextMenu to show. 

Thanks!

2 Answers, 1 is accepted

Sort by
0
Kate
Telerik team
answered on 17 Oct 2013, 09:28 AM
Hi Sam,

One approach that you can try is to check the target element and cancel the OnClientShowing event of the RadContextMenu. Thus you will prevent the menu from showing on the specific controls. Below you can find some very useful help articles that will provide with simple example to get you started:

http://www.telerik.com/help/aspnet-ajax/menu-context-menus.html
http://www.telerik.com/help/aspnet-ajax/menu-onclientshowing.html

Regards,
Kate
Telerik
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 the blog feed now.
0
Sam
Top achievements
Rank 1
answered on 23 Oct 2013, 07:40 PM
Thanks Kate.  That's just what I needed.
This is what I ended up with

function OnClientShowing(menu, args) {
    var target = args.get_targetElement();
    if (target) {
        var elementType = "";
        elementType = target.nodeName.toLowerCase();
        if (elementType == "input" || elementType == "textarea") {
            args.set_cancel(true);
        }
    }
}
Tags
Menu
Asked by
Sam
Top achievements
Rank 1
Answers by
Kate
Telerik team
Sam
Top achievements
Rank 1
Share this question
or