Home > Back-end >  Create rich text editor with content editable div in asp.net web forms
Create rich text editor with content editable div in asp.net web forms

Time:10-28

I have a little problem. I need to create a text editor in asp.net webforms. Therefore I managed to create only a div which is content editable. I like to ask, in this code, can I add some more functions, for example converting the selected text to upper case, lower case, add bullets, change fore and background color and so on. I have tried to add upper and lower case, but it needs to be in a text area, not in a div. For the bold, italic and underline functions to work, they need to be on a content editable div. Here is my code, thanks in advance!

<div id="txtPrev" contenteditable="true">Some example text</div>
<a href="#"  onclick="emboldenFont()">B</a>
<a href="#"  onclick="italicFont()">I</a>
<a href="#"  onclick="underFont()">U</a>

<script>
    function emboldenFont() {
        document.execCommand('bold', false, null);
    }
    function italicFont() {
        document.execCommand('italic', false, null);
    }
    function underFont() {
        document.execCommand('underline', false, null);
    }
</script>

CodePudding user response:

The problem is solved with using an editor in my project.

  • Related