How to disable make changes using HTML mode

1 Answer 53 Views
Editor
Emin Sadigov
Top achievements
Rank 2
Iron
Iron
Iron
Emin Sadigov asked on 12 Jul 2024, 03:15 PM

Hello,

Is any standard method to disable edit in the HTML mode available?

HTML mode must be visible to show output code, but now allowed for users to edit using it, only using Design.

Thank you.

1 Answer, 1 is accepted

Sort by
0
Rumen
Telerik team
answered on 12 Jul 2024, 03:22 PM | edited on 12 Jul 2024, 03:23 PM

Hi Emin,

To disable editing in the HTML mode of RadEditor while still allowing users to view the HTML code, you can use the following approach. This method ensures that users can see the HTML content but cannot modify it when in HTML mode

<telerik:RadEditor runat="server" ID="RadEditor1" Height="600px" OnClientModeChange="OnClientModeChange">
    <Content></Content>
</telerik:RadEditor>

<script>
    function OnClientModeChange(editor, args) {
                
            var mode = editor.get_mode();
            if (mode == 2) { // Check if the mode is HTML
                setTimeout(function () {
                    var htmlMode = editor.get_textArea();
                    htmlMode.disabled = "true"; // Disable editing
                }, 100); 
            }
                
    }
</script>

For more information, you can refer to this documentation:


Best Regards,
Rumen
Progress Telerik

Stay tuned by visiting our public roadmap and feedback portal pages! Or perhaps, if you are new to our Telerik family, check out our getting started resources
Tags
Editor
Asked by
Emin Sadigov
Top achievements
Rank 2
Iron
Iron
Iron
Answers by
Rumen
Telerik team
Share this question
or