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

7 posts, 0 answers
  1. Telerik Admin
    Telerik Admin avatar
    1679 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. renas
    renas 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. Rumen
    Admin
    Rumen avatar
    12851 posts

    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. renas
    renas 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. HHH
    HHH 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. Rumen
    Admin
    Rumen avatar
    12851 posts

    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. HHH
    HHH 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