Click here to Skip to main content
Click here to Skip to main content

Rich Text Editor with ASP.NET

By , 11 Sep 2012
 

Introduction

As we know, ASP.NET lack a Control, that we need most, RichText Editor. 
If you are trying to create a application or website with Admin Panel or Blog or Forum Website or something such project for Web in ASP.NET platform, we need RickText Editor. 
To overcome from this, we can use Many open source JavaScript based editors, like Tiny MCE, FCKEditor, etc. 

Content 

In this Article, we would learn how to Implement Free RichText Editor into ASP.NET website. We are using TinyMCE editor here.
We are using TinyMCE, which is One of most popular and Open Source project. Download latest version of TinyMCE from Download Page, and Extract the Zip File.
Browse the Extracted Location and go to ..\tinymce_3.5.6\tinymce\jscripts folder.
Now Copy the tinymce folder from above Location to your Solution in Visual Studio.
Add a Page where you want to Implement RichTextbox and Design the Page.
Now lets Move to Topic. How to Add TinyMCE in Page and Richtext box Control placed for Content of Blog in above sample.
Insert JavaScript file tiny_mce.js in Web Page and some also initialize this function.
This Code into head Section.
  <script type="text/javascript" src="tiny_mce/tiny_mce.js"></script>
    <script type="text/javascript" language="javascript">
        tinyMCE.init({
            // General options
            mode: "textareas",
            theme: "advanced",
            plugins: "pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups",
           
        });
    </script>
Note: You can so many settings, look in Samples and Help Doc of TinyMCE.
Now Run the Page. Look, how it looked.
Without any additional Practice, our TextBox with Multiline turned into RichText Editor.
Now, its ok as per Requirement. No, when you will send Command to Server, it will return Error Like below.
We have to add just One Line of Code in Web.config file and one property in Default.aspx form (Page with Rich Text Editor).
That is : 
in web.config:
<configuration>
  <system.web>
    <compilation debug="true" targetFramework="4.0"/>
    <httpRuntime requestValidationMode="2.0"/>
  </system.web>
</configuration>
and in Page directive:
ValidateRequest = "false"
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" ValidateRequest="false" %> 
Now, you can save the Data in Database, Do postback, retrieve same in Rich Text box and do anything you want.  

  

Conclusion: 

IT is Jugad. So enything is possible here. Don't be worry about things that are not available. Just modify and make use of things those are available. Tiny MCE is one of the most known and Popular Rich Text editor (WYSIWYG).

Reference: 

http://www.tinymce.com/download/download.php 

License

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

About the Author

John Bhatt
Software Developer (Senior) P.Yar.B Complex
Nepal Nepal
Member
John Bhatt is an IT Professional having interest in Web technology. He is Web Designer, Developer, Software Developer, Blogger and Technology Geek. Currently he writes his Blogs at Blog of P.Yar.B and various other Sites. He is Main author and founder of Download Center.
Contact Him at : Facebook | Twitter | Website.

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page   
QuestionSql Injection Pinmembersaerluvla Arul21 Mar '13 - 20:05 
AnswerRe: Sql Injection PinmemberJohn Bhatt14 Apr '13 - 20:05 
QuestionRE: your post abt rich text box PinmemberMember 983287813 Feb '13 - 4:54 
AnswerRe: RE: your post abt rich text box PinmemberJohn Bhatt14 Apr '13 - 20:03 
QuestionLimited tools Pinmemberdeivisvieira15 Jan '13 - 6:40 
AnswerRe: Limited tools PinmemberJohn Bhatt15 Jan '13 - 19:30 
GeneralThanks Pinmemberh_salimi4 Dec '12 - 3:08 
GeneralRe: Thanks PinmemberJohn Bhatt4 Dec '12 - 3:51 
QuestionA potentially dangerous Request.Form value was detected from the client (ctl00$ContentPlaceHolder1$RichTextBox="<p>TEST!</p>"). Pinmembersaerluvla Arul1 Nov '12 - 0:11 
AnswerRe: A potentially dangerous Request.Form value was detected from the client (ctl00$ContentPlaceHolder1$RichTextBox="<p>TEST!</p>"). PinmemberJohn Bhatt1 Nov '12 - 1:17 
QuestionRe: A potentially dangerous Request.Form value was detected from the client (ctl00$ContentPlaceHolder1$RichTextBox="<p>TEST!</p>"). Pinmembersaerluvla Arul1 Nov '12 - 2:38 
AnswerRe: A potentially dangerous Request.Form value was detected from the client (ctl00$ContentPlaceHolder1$RichTextBox="<p>TEST!</p>"). PinmemberJohn Bhatt1 Nov '12 - 3:07 
QuestionHelp doc PinmemberAmalraj Ramesh12 Feb '13 - 1:43 
GeneralMy vote of 4 Pinmembersaerluvla Arul24 Oct '12 - 19:42 
GeneralRe: My vote of 4 PinmemberJohn Bhatt25 Oct '12 - 3:44 
GeneralThanks! Pinmembersaerluvla Arul27 Oct '12 - 2:11 
GeneralRe: Thanks! PinmemberJohn Bhatt27 Oct '12 - 2:18 
QuestionHow do you validate against attacks? PinmemberPhilippe Mori11 Sep '12 - 10:13 
AnswerRe: How do you validate against attacks? PinmemberJohn Bhatt11 Sep '12 - 19:11 
Generalthanks PinmemberSirwan Afifi11 Sep '12 - 10:10 
GeneralRe: thanks PinmemberJohn Bhatt26 Sep '12 - 22:16 

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

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

Permalink | Advertise | Privacy | Mobile
Web04 | 2.6.130523.1 | Last Updated 11 Sep 2012
Article Copyright 2012 by John Bhatt
Everything else Copyright © CodeProject, 1999-2013
Terms of Use
Layout: fixed | fluid