Asp .Net Rich Text Editor


This article is written by Pon Saravanan  on 09-Dec-09 Last modified on :28-Dec-09





Javscript Based Editor to use in ASP.Net

Please don’t get confused with Rich Text Editor in VB6 or classic VB. Those are  all working with RTF which is know as rich text format. This rich text editor I am explaining also providing rich text editing, but the format is HTML. So it has its own limitations (For e.g... unable to paste Image data directly). And it is actually a JavaScript code so it is not written asp.net but can be used along with ASP.Net applications as I am doing for this website.

Please note that, this is not a 100% working source code for Rich Text Editor. However if you are just looking for an editor which supports hyperlinks and few word formatting. This article will be helpful for you to proceed.

IFRAME Based Approach

It is basically very easy to build a simple editor using IFRAME. But the real trouble comes in when trying to build a editor which supports most of the word processing application.

Bring the IFRAME to Editable using designMode

IFRAME can be used as a editor once the design mode is set as on as shown in the following code.
<IFRAME ID="EditorFrame"></IFRAME> <SCRIPT> frames.myEditor.document.designMode = "On" </SCRIPT>

Built in shortcuts to format

The basic formatting like bold, italics, and underline can be done with the shortcuts CTRL +B, CTRL + I, CTRL+U respectively. All the fully qualified URLS will be considered as hyperlinks once after pressing enter or pasting (next to the hyperlink). So without much code you can start using the IFRAME as a editor.

Adding Toolbar to the editor

Still need more functionality like adding images and formatting using a tool bar?  You may use the commands to fire

var EditorFrame = frames. EditorFrame.document.selection.createRange()
EditorFrame.execCommand("Bold")

You may use the commands using execCommand of the Range object of the selection. Most of the functionalities can be programmed using this. If you want something beyond this. It is time to go for a component which has those functionalities. Because the amount of knowledge it may need to program using javascript is very high in my opinion. There are really very good components available in the market for Rich Text Editors.











Comments

Comments
   
Captcha Image
For you specially:  
Captcha Text Enter the text in the image.(Not Case sensitive)    



Spam Bot Trap



   



Select Theme
White
Blue
Brown
Gray