Not allow copy any data in radeditor control

7 posts, 0 answers
  1. Jiten
    Jiten avatar
    57 posts
    Member since:
    Sep 2012

    Posted 06 Jan 2015 Link to this post

    Hello,

      I am looking to block any kind copy in radeditor control like CTRL+C and Mouse Right Click and copy option.


    This is basic requirement of security for clinical prospective.
    Please help me to solve this issue.

    Thanks.
  2. Ianko
    Admin
    Ianko avatar
    1535 posts

    Posted 08 Jan 2015 Link to this post

    Hello Jiten,

    The following implementation should do the job:
    <telerik:RadEditor runat="server" ID="RadEditor1" OnClientLoad="OnClientLoad">
    </telerik:RadEditor>
     
    <script type="text/javascript">
        function OnClientLoad(sender, args) {
            // Disable copying from Design and Preview mode
            $telerik.addExternalHandler(sender.get_contentArea(), "copy", function myfunction(ev) {
                alert("This content cannot be copied!");
                $telerik.cancelRawEvent(ev);
            });
     
            // Disable copying from HTML mode
            $telerik.addExternalHandler(sender.get_textArea(), "copy", function myfunction(ev) {
                alert("This content cannot be copied!");
                $telerik.cancelRawEvent(ev);
            });
        }
    </script>


    Regards,
    Ianko
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Jiten
    Jiten avatar
    57 posts
    Member since:
    Sep 2012

    Posted 08 Jan 2015 in reply to Ianko Link to this post

    Thanks a lot.
    Your solution is great.
  5. Jiten
    Jiten avatar
    57 posts
    Member since:
    Sep 2012

    Posted 15 Jan 2015 Link to this post

    Your solution working fine but my medical Illustration command link not enable in RadEditor. So I could not open the medical Illustration page.
    Here is my code:
    <telerik:RadEditor runat="server" ID="RTF1" EnableTextareaMode="false" Skin="Office2007" ContentFilters="None"
                                        Width="99%" Height="440px" AutoResizeHeight="false" StripFormattingOptions="NoneSupressCleanMessage"
                                        ToolsFile="~/Include/XML/WordProcessorEditorTools.xml" OnClientSelectionChange="OnClientSelectionChange"
                                        OnClientLoad="OnClientLoad" OnClientPasteHtml="OnClientPasteHtml">
                                        <CssFiles>
                                            <telerik:EditorCssFile Value="~/EditorContentArea.css" />
                                        </CssFiles>
                                        <SpellCheckSettings AllowAddCustom="true" />
                                        <ImageManager ViewPaths="~/medical_illustration" />
                                    </telerik:RadEditor>


    And Javascript:
    <script type="text/javascript">
        function OnClientLoad(sender, args) {
            // Disable copying from Design and Preview mode
            $telerik.addExternalHandler(sender.get_contentArea(), "copy", function myfunction(ev) {
                alert("This content cannot be copied!");
                $telerik.cancelRawEvent(ev);
            });

            // Disable copying from HTML mode
            $telerik.addExternalHandler(sender.get_textArea(), "copy", function myfunction(ev) {
                alert("This content cannot be copied!");
                $telerik.cancelRawEvent(ev);
            });
        }
    </script>
    Also I attach image file. Please see the image and give me the solution.

    I Hope will give me the solution.

    Thanks.
  6. Ianko
    Admin
    Ianko avatar
    1535 posts

    Posted 15 Jan 2015 Link to this post

    Hi,

    I am not sure if I can define how this custom command is related to the copy restriction or what is wrong with it.

    Could you provide more details about it, so that I could understand the situation?

    Regards,
    Ianko
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  7. Jiten
    Jiten avatar
    57 posts
    Member since:
    Sep 2012

    Posted 17 Jan 2015 in reply to Ianko Link to this post

    I use this javascript code in OnClientLoad property to enable medical illustration link command in rad editor:
    <script type='text/javascript'>
            function OnClientEditorLoad(editor, args) {
                var style = editor.get_contentArea().style;
                style.fontFamily = 'Tahoma';
                style.fontSize = 11 + 'pt';

                var mode = editor.get_mode();

                switch (mode) {
                    case 4:
                        setTimeout(function() {
                            var ImageEditor = editor.getToolByName("ImageEditor");
                            var MedicalIllustration = editor.getToolByName("MedicalIllustration");
                            var ExportToRtf = editor.getToolByName("ExportToRtf");

                            ImageEditor.setState(0);
                            MedicalIllustration.setState(0);
                            ExportToRtf.setState(0);
                        }, 0);
                        break;
                }
            }
        </script>

    Another point is restriction to copy the radeditor data I use OnClientLoad property in radeditor javascript code is here:
    <script type="text/javascript">
        function OnClientLoad(sender, args) {
            // Disable copying from Design and Preview mode
            $telerik.addExternalHandler(sender.get_contentArea(), "copy", function myfunction(ev) {
                alert("This content cannot be copied!");
                $telerik.cancelRawEvent(ev);
            });

            // Disable copying from HTML mode
            $telerik.addExternalHandler(sender.get_textArea(), "copy", function myfunction(ev) {
                alert("This content cannot be copied!");
                $telerik.cancelRawEvent(ev);
            });
        }
    </script>
    I have achieved one functionality either medical illustration Link Command or restriction copy.

    My Point is how we go these two functionalists in rad editor control.
    I hope you understand my query.

    Please help me as soon as possible.
    Thanks your reply. I appreciate.
  8. Ianko
    Admin
    Ianko avatar
    1535 posts

    Posted 20 Jan 2015 Link to this post

    Hi,

    The provided code is only an example, it is not a must to add it as it is in your code.

    If you already have a handler method attached to the load event of the RadEditor you can further add the same logic to to implement the additional functionality. I.e., you need to merge the OnClientEditorLoad and the OnClientLoad methods.

    If this is not the case, please provide exact details about the custom tools, the expected behavior and the result you are getting. Also, it would be best if you could isolate the difficulties encountered in a sample solution, so that I could be able to examine the exact situation and suggest proper solutions as per to the exact scenario.

    Regards,
    Ianko
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017