Make RadContextMenu ignore input controls

3 posts, 0 answers
  1. Sam Tran
    Sam Tran avatar
    84 posts
    Member since:
    Nov 2006

    Posted 14 Oct 2013 Link to this post


    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. 

  2. Kate
    Kate avatar
    1898 posts

    Posted 17 Oct 2013 Link to this post

    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:

    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.
  3. Sam Tran
    Sam Tran avatar
    84 posts
    Member since:
    Nov 2006

    Posted 23 Oct 2013 Link to this post

    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") {
Back to Top