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

Thread is closed for posting
7 posts, 0 answers
  1. 63F75A2C-1F16-4AED-AFE8-B1BBD57646AD
    63F75A2C-1F16-4AED-AFE8-B1BBD57646AD avatar
    1572 posts
    Member since:
    Oct 2004

    Posted 17 Mar 2006 Link to this post

     

    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
     
  2. 0979DFE4-0612-458B-A4C3-E18AB8F268AF
    0979DFE4-0612-458B-A4C3-E18AB8F268AF avatar
    2 posts
    Member since:
    Jun 2007

    Posted 19 Jun 2007 Link to this post

    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.
  3. DF60784D-55A5-4263-9F10-A12FA48C9ADC
    DF60784D-55A5-4263-9F10-A12FA48C9ADC avatar
    14477 posts
    Member since:
    Apr 2022

    Posted 20 Jun 2007 Link to this post

    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
  4. 0979DFE4-0612-458B-A4C3-E18AB8F268AF
    0979DFE4-0612-458B-A4C3-E18AB8F268AF avatar
    2 posts
    Member since:
    Jun 2007

    Posted 20 Jun 2007 Link to this post

    Dear Rumen,
    Yes,it's my stupid fault to set the enableTab property to 'true'.
    My appreciation to you,thanks a lot.
  5. 8E7F6F14-0424-4971-A8FE-8DEB5F75BC04
    8E7F6F14-0424-4971-A8FE-8DEB5F75BC04 avatar
    42 posts
    Member since:
    Feb 2008

    Posted 20 Mar 2008 Link to this post

    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
    }

    }

    });

    }

  6. DF60784D-55A5-4263-9F10-A12FA48C9ADC
    DF60784D-55A5-4263-9F10-A12FA48C9ADC avatar
    14477 posts
    Member since:
    Apr 2022

    Posted 21 Mar 2008 Link to this post

    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
  7. 8E7F6F14-0424-4971-A8FE-8DEB5F75BC04
    8E7F6F14-0424-4971-A8FE-8DEB5F75BC04 avatar
    42 posts
    Member since:
    Feb 2008

    Posted 21 Mar 2008 Link to this post

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

This Code Library is part of the product documentation and subject to the respective product license agreement.