VB .Net Tutorial

A tutorial on Visual Basic …

Javascript based Rich Text Editor for asp.net

without comments

VB.Net Tutorial: Iframe Based Editor using Javascript
Please don’t get confused with Rich Text Editor in classic VB. These controls are working with rich text format. The editor, I am explaining here also providing rich text editing. However the final format is HTML..
So it has its own limitations, For example it can not paste Image data directly. And it is actually a JavaScript which turns a iframe as a editor. So it is not written in asp.net but can be used in ASP.Net applications. This is what I am doing for few of my websites.
I don’t have a 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 can help you to code one for your simple needs.
IFRAME as an editor
It is relatively very easy to build an editor using an IFRAME. But the real trouble comes in when trying to build an editor similar to a word processor like a Microsoft office word.
Bring the IFRAME to Editable mode using designMode
IFRAME can be used as an editor once the design mode is set to ‘ON’ as shown in the following code.


Native formatting abilities
The basic formatting like bold, italics, and underline natively supported with the shortcuts CTRL +B, CTRL + I, CTRL+U respectively. All the fully qualified URLS will be considered as hyperlinks once after pasting followed by pressing enter or pasting (next to the hyperlink). So without much code you can start using the IFRAME as an editor.
Specific formatting using a toolbar
If you still need more functionality like adding images and formatting using a tool bar .You may use the following syntax to fire commands
var EditorFrame = frames. EditorFrame.document.selection.createRange()
EditorFrame.execCommand(“Bold”)
You can use the commands using ‘execCommand’ on the Range object of the Selection. Majority of the operations can be programmed like this to function as you expect.

Written by admin

December 16th, 2010 at 9:16 am

Posted in Classic VB