Allowing Creativity with Rich Text
In ASP.NET, we can use a RichTextBox control to allow users to enter and edit formatted text. This control is similar to the regular TextBox control, but it includes a formatting toolbar that allows users to change the font, size, color, and style of the text.
To add a RichTextBox control to an ASP.NET web form, follow these steps:
Open the web form in Design view.
From the Toolbox, drag a RichTextBox control onto the form.
Set the properties of the RichTextBox control, such as its ID, height, and width.
Add any additional formatting options to the control, such as font and size choices.
When the user submits the form, the text from the RichTextBox control can be accessed in the code-behind file using the control’s ID and the Text property.
An ASP.NET TextBox actively discourages rich text such as italic and bold. If you enter the following markup, ASP.NET complains about a “potentially dangerous” value.
I’m <i>entering</i> markup the <b>hard</b> way.
Text editor add-ons give you word processor-like capabilities in a text box. You can download the free Rich Text Editor (RTE) from http://rte.codeplex.com/. Another popular control is CKeditor.Net.
Look for CKeditor.Net at http://ckeditor.com/.