Click here to Skip to main content
15,167,425 members
Articles / Web Development / ASP.NET
Posted 16 Jun 2010

Tagged as


36 bookmarked

Integrating TinyMCE Editor with ASP.NET

Rate me:
Please Sign up or sign in to vote.
4.75/5 (14 votes)
16 Jun 2010CPOL2 min read
Integrating TinyMCE editor with ASP.NET


In one of my projects, there was a requirement to embed a WYSIWYG editor. Some of the features that were looked into were:

  • Easy to configure
  • Open source
  • In some cases, user can edit only portion of the pre-rendered text in the editor.

After searching a lot, I came across TinyMCE editor ( But, I had some issues in integrating the same with ASP.NET applications. The following write up provides one of the ways to integrate with TinyMCE.

How To

The following section provides the steps to implement it in ASP.NET.

Step 1: Download the latest version ( from the following location, Unzip the downloaded .zip file in one of your local folders.

Step 2: Create an ASP.NET web application and copy the tinymce folder to the web application. The solution explorer would look something like this.


Note: You can remove the examples folder under tinymce folder.

Step 3: Add a reference of tiny_mce.js file to the page in which you would like to integrate the TinyMCE editor.

Include tiny_mce.js file at the top of your file.

<script type="text/javascript" src="tinymce/jscripts/tiny_mce/tiny_mce.js"></script> 

Add the following lines of code which initialize all the textarea controls on the WYSIWYG editor type. They are quite customizable, please check the examples section in their web site.

<script type="text/javascript"> 
// General options 
mode: "textareas", 
theme: "advanced", 
plugins: "pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,
setup: function(ed) { 
function(ed, evt) { 
// Theme options 
theme_advanced_buttons1: "save,newdocument,|,bold,italic,underline,strikethrough,|,
theme_advanced_buttons2: "cut,copy,paste,pastetext,pasteword,|,search,replace,|,
theme_advanced_buttons3: "tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,|,
theme_advanced_buttons4: "insertlayer,moveforward,movebackward,absolute,|,
theme_advanced_toolbar_location: "top", 
theme_advanced_toolbar_align: "left", 
theme_advanced_statusbar_location: "bottom", 
theme_advanced_resizing: true, 
// Example content CSS (should be your site CSS) 
content_css: "css/content.css", 
// Drop lists for link/image/media/template dialogs 
template_external_list_url: "lists/template_list.js", 
external_link_list_url: "lists/link_list.js", 
external_image_list_url: "lists/image_list.js", 
media_external_list_url: "lists/media_list.js", 
// Style formats 
style_formats: [ 
{ title: 'Bold text', inline: 'b' }, 
{ title: 'Red text', inline: 'span', styles: { color: '#ff0000'} }, 
{ title: 'Red header', block: 'h1', styles: { color: '#ff0000'} }, 
{ title: 'Example 1', inline: 'span', classes: 'example1' }, 
{ title: 'Example 2', inline: 'span', classes: 'example2' }, 
{ title: 'Table styles' }, 
{ title: 'Table row 1', selector: 'tr', classes: 'tablerow1' } 
// Replace values for the template plugin 
template_replace_values: { 
username: "Some User", 
staffid: "991234" 

Step 4: Add a text area control on to the page.

<textarea id="elm1" name="elm1" rows="15" cols="80" style="width: 80%" 

Step 5: Execute the Page J and you should able to see the editor embedded in your ASP.NET page.


Additional Features

In case you would want to have pre rendered text with some non editable text, use the CSS class mceNonEditable for the text you would want to make it non editable.

this.elm1.Value = "<p>This is a test document. 
Some <span class='mceNonEditable' style=\"color: #ff0000;\">Portion</span> 
of this document can't be changed.</p>\r\n<p>The area with red 
<span class='mceNonEditable' style=\"color: #ff0000;\">background </span>
can't be <span class='mceNonEditable' style=\"color: #ff0000;\">removed</span>. 
You can only <span class='mceNonEditable' style=\"color: #ff0000;\">change </span>
the area with black.</p>\r\n<p>&nbsp;</p>"; 

Where this.elm1 is a textarea control.


I had difficulties in getting it to work, hence thought this should be useful for people wanting to integrate the TinyMCE editor with their ASP.NET applications.


  • 16th June, 2010: Initial post


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Manjunath Shrikantiah
India India
9+ plus years of experience in IT industry. This includes experience in architecting, designing and developing solutions on Web and desktop application platforms

Comments and Discussions

SuggestionSolved my issue with TinyMCE for ongoing project Pin
Nancy Dsouza4-Jan-15 10:39
MemberNancy Dsouza4-Jan-15 10:39 
QuestionIt saved my hours! Pin
jignesh.hRathod11-Dec-12 6:30
Memberjignesh.hRathod11-Dec-12 6:30 
QuestionTinyMCE does not work in my project Pin
jackthomson17-Dec-11 23:58
Memberjackthomson17-Dec-11 23:58 
AnswerRe: TinyMCE does not work in my project Pin
mbielski28-Jul-12 5:07
Membermbielski28-Jul-12 5:07 
GeneralRe: TinyMCE does not work in my project Pin
purushottamahire17-Dec-12 1:00
Memberpurushottamahire17-Dec-12 1:00 
GeneralRe: TinyMCE does not work in my project Pin
Member 793937831-Dec-12 19:16
MemberMember 793937831-Dec-12 19:16 
GeneralWith Ajax Not post back Pin
zubair0130-Jan-11 3:35
Memberzubair0130-Jan-11 3:35 
GeneralRe: With Ajax Not post back Pin
Manjunath Shrikantiah30-Jan-11 18:56
MemberManjunath Shrikantiah30-Jan-11 18:56 
GeneralRe: With Ajax Not post back [modified] Pin
zubair012-Feb-11 7:50
Memberzubair012-Feb-11 7:50 
GeneralMy vote of 5 Pin
Bo Vistisen25-Nov-10 1:32
MemberBo Vistisen25-Nov-10 1:32 
Nice and simple. Full working code sample and precise article. Good job.
QuestionDid you try the HTML Editor that ships with the AJAX Control Toolkit? Pin
rc10023-Jul-10 10:30
Memberrc10023-Jul-10 10:30 
AnswerRe: Did you try the HTML Editor that ships with the AJAX Control Toolkit? Pin
Manjunath Shrikantiah25-Jul-10 21:25
MemberManjunath Shrikantiah25-Jul-10 21:25 
GeneralNice little article. Pin
mbielski22-Jun-10 5:27
Membermbielski22-Jun-10 5:27 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.