New to Telerik UI for ASP.NET AJAX? Download free 30-day trial

Disable RadEditor and browser context menus for a specific HTML element

Environment

Product RadEditor for ASP.NET AJAX

Description

Learn how to hide the RadEditor context menu and not to show the default browser's context menu for a specific FORM element tag - SELECT

Solution

The solution is the following:

    <script type="text/javascript">
        function CallContextMenu(editor) {
            editor.attachEventHandler("oncontextmenu", function (e) {
                var oSelection = editor.getSelection().getParentElement(); //get the selected element
                if (oSelection.tagName.toLowerCase() == "select") {
                    $telerik.cancelRawEvent(e); //disable the browser's context menu 
                    return false;
                }
            });
        }
    </script>
    <telerik:RadEditor runat="server" ID="RadEditor1" OnClientLoad="CallContextMenu">
        <Content>
            <select disabled="true"> <option selected="true">Content A</option> </select>
        </Content>
    </telerik:RadEditor>
    protected void Page_Load(object sender, EventArgs e)
    {
        RadEditor1.ContextMenus.FindByTagName("SELECT").Enabled = false; //disable the RadEditor's context menu for select elements
    }
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
        RadEditor1.ContextMenus.FindByTagName("SELECT").Enabled = False
    End Sub

See Also

In this article