As we know, ASP.NET lack a Control, that we need most, RichText Editor. To overcome from this, we can use Many open source editors. In this Article, we would learn how to Implement Free RichText Editor into ASP.NET website.
Requirement of RichText Editor in ASP.NET ?
In this Article, we will 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
Extract and Paste TinyMCE Script in your Visual Studio Solution
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.
tiny_mce.js in Web Page and some also initialize this function. Add below Code into head section.
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. But No, when you will send command to Server (submit form), 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 RichText Editor).
<configuration> <system.web> <compilation debug="true" targetFramework="4.0"/> <httpRuntime requestValidationMode="2.0"/> </system.web> </configuration>
And in Page directive:
ValidateRequest = "false"
After adding Page directive code, your line will be like below..
<%@ 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.
So anything 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).