Hi folks
I want to replace the standard text box in a templatefield for say a gridview or formview control with a "smart text box" so the users can have more control when creating a new record or editing an existing record in the DB.
I guess the main facilities I would like them to have is as follows:
- new paragraph
- bold
- italics
- indent/outdent
Perhaps I am making a fundamental error, but I presume when say the data is submitted to the DB from this page (Write a New Post), there is embedded in it various HTML elements such as
or .
Is there any reasonably straight forward way this can be done?
Kind regards and thanks in advance
Ross
It sounds like what you are looking for is a Rich Text Editor (much like the one I am typing in to write this).
There are actually numerous Rich Text Editors that you can use within ASP.NET (or outside of it as well).
Some of the most common Javascript based ones are listed below :
- Redactor (probably the best editor out there)
- CKEditor
- Tiny MCE
- HTML Editor
(Additional discussion available here)
If you are familar with the AJAXControlToolkit, a common set of controls and extensions for Web Forms, then you may want to consider checking out their HTMLEditorExtender as
well, which would simply require you to just drop the necessary control within your page.
Actual Implementations within GridViews
I would recommend checking out the following discussions from this forum, which will detail and answer some of the questions that you may have for implementing one of these editors within your GridView itself :
- Using an HTML Editor within a TemplateField
- Using an HTML Editor as a Grid Editing Option
- HTML Editor within a GridView
Additional Details
When dealing with actual HTML, you'll just need to ensure that you are encoding the values when saving your HTML data and will need to set the validateRequest property to false for that Page :
<%@ Page ValidateRequest="false" ... %>
This will allow your HTML tags to be passed up to your code-behind when you attempt to save your content. It can be helpful to handle both encoding and decoding this content as well, which can be done through the
HtmlEncode() and
HtmlDecode() methods respectively.
Hi Rion
Thanks for your help.
I will try your suggestions.
Thanks
Ross
沒有留言:
張貼留言