Skip Navigation LinksHome / Community & Support / Code Library / ASP.NET and ASP.NET AJAX > Editor > Disable/enable r.a.d.editor 5.0 with client-side script

Disable/enable r.a.d.editor 5.0 with client-side script

Feed from this thread
  • Posted on Mar 17, 2006 (permalink)

     

    Requirements

    r.a.d.editor version

    5.x - 7.x

    .NET version

    all

    Visual Studio version

    all

    programming language

    JavaScript

    browser support

    Internet Explorer 6+


    You can use the provided javascript code in the attached example to make the editor ReadOnly. The user will neither be able to type nor to apply formatting to the content.

    To run it, simply extract the content of the archive to your web application (having RadEditor) root folder and start the aspx file from your browser.

    ATTENTION: This solution is applicable only to Internet Explorer
     
    Attached files

    Reply

  • Posted on Jun 19, 2007 (permalink)

    hi,thank you for your example. But I find there's a problem when I press TAB till the cursor gets in the content area,then I could type characters. Would you please give some help? Thank you very much.

    Reply

  • Rumen Rumen admin's avatar

    Posted on Jun 20, 2007 (permalink)

    Hi Zhang,

    I tried to reproduce the problem with RadEditor 7.1.1 by pressing the Tab key, but without success. The content area was still disabled.

    Nevertheless, you can try the following two solutions that can help you to solve the problem on your end.

    Solution 1#:
    If you use RadEditor 7.x in your project then replace the SetEditable() method in the code:

    editor.SetEditable(toEnable);
            
    with the new one named EnableEditing() implemented in v7.x of RadEditor:

    editor.EnableEditing(toEnable);


    Solution 2#:
    Disable the TAB key  pressing in the content area by modifying a bit the DisableTyping function:

    if (!isEnabled && e.keyCode == 9)
    {
        e.returnValue = false;
        e.cancelBubble = true;
        return false;
    }

    You should also set the editor's EnableTab property to "false".

    Kind regards,
    Rumen
    the Telerik team

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

    Reply

  • Posted on Jun 20, 2007 (permalink)

    Dear Rumen,
    Yes,it's my stupid fault to set the enableTab property to 'true'.
    My appreciation to you,thanks a lot.

    Reply

  • HHH avatar

    Posted on Mar 20, 2008 (permalink)

    Hey there,

    I m using prometheus and how to disable User Typing only typing(allow formatting) 

    function

    OnClientLoad(editor, args)

    {

    editor.attachEventHandler(

    "onkeydown", function(e)

    {

    var editor = $find("<%=RadEditor1.ClientID%>");

    var theSelectionObject = editor.getSelection();

    var theSelectedElement = theSelectionObject.getParentElement();

    if (theSelectedElement)

    {

    if ( theSelectedElement.className == "BmiNonEditable")

    {

     ///////////   code to disable User typing here
    }

    }

    });

    }

    Reply

  • Rumen Rumen admin's avatar

    Posted on Mar 21, 2008 (permalink)

    Hi,

    Here is the requested example for RadEditor "Prometheus":

    <script type="text/javascript"
    function OnClientLoad(editor, args) 
        editor.attachEventHandler("onkeydown", DisableTyping); 
        function DisableTyping(e) 
        { 
            var theSelectionObject = editor.getSelection(); 
            var theSelectedElement = theSelectionObject.getParentElement(); 
            if (theSelectedElement) 
            { 
                while (theSelectedElement.tagName != "BODY"
                { 
                    if (theSelectedElement.className == "BmiNonEditable"
                    { 
                        if (!document.all) 
                        { 
                            e.preventDefault(); 
                            e.preventBubble(); 
                            e.stopPropagation(); 
                        } 
                        else 
                        { 
                            e.returnValue = false
                            e.cancelBubble = true
                        } 
                        return false;     
                    } 
                    theSelectedElement = theSelectedElement.parentNode; 
                     
                } 
            } 
        } 
    </script> 
     
    <telerik:RadEditor OnClientLoad="OnClientLoad" ID="RadEditor1" runat="server"
        <Content> 
            <div class="BmiNonEditable" style="border: 1px solid red;">you cannot type here</div> 
            <div style="border: 1px solid green;">you can type here</div>     
        </Content> 
    </telerik:RadEditor> 


    Best regards,
    Rumen
    the Telerik team

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

    Reply

  • HHH avatar

    Posted on Mar 21, 2008 (permalink)

    Thanks man,
    Good one..
    it working now.
    cool
    thanks again.

    Reply

Back to Top

Skip Navigation LinksHome / Community & Support / Code Library / ASP.NET and ASP.NET AJAX > Editor > Disable/enable r.a.d.editor 5.0 with client-side script