HTML Text Editor

This blog will explain the use of HTML Text Editor with an example.

In this blog, we will explain the use of HTML Text Editor in ASP.NET by using TinyMCE RichTextBox plugin.

Step 1

First of all, add a Web application and name it "Web Application".

Step 2

Now, in this application we will add a textarea, one button, and a div.

  1. <div> <textarea id="txtarea"></textarea> <input type="button" id="btnValue" value="Get Value" />  
  2.     <div id="divkarea">   
  3. </div>  

Step 3

Now, add JQuery Link and Tinymce link.

  1. <script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>  
  2. <script type="text/javascript" src="//tinymce.cachefly.net/4.0/tinymce.min.js"></script>  

Step 4

Now, add Tinymce function To make Textarea as Editor.

  1. <script type="text/javascript">  
  2.     tinymce.init({  
  3.         selector: 'textarea',  
  4.         width: 500  
  5.     });  
  6. </script>  

Step 5

Now, add jQuery function to Textarea content and add to div.

  1. $(document).ready(function() {  
  2.     $('#btnValue').click(function() {  
  3.         $("#divkarea").html("");  
  4.         var content = tinymce.get("txtarea").getContent();  
  5.         $("#divkarea").html(content);  
  6.     });  
  7. });