views:

3007

answers:

2

Dear all, I save formatted text (bold, changed in font, style...etc) in an nvarchar(max) field, its for some Description field, on another stage, I want to be able to edit this description, so in the Editing Page, I read the original inoformation, fill it in the fields and wait for the user to change it and save, this is working for all kinds of normal text fields, and also with normal text displayed in a text area, but when I fill the text area with the styled text, it shows the HTML code and not it result, so for instance, it shows:

<span style="font-weight: bold; text-decoration: line-through;">SM</span><span style="background-color: rgb(51, 102, 255);">ART</span><br>

Instead of a what it should look like, any suggestions on how I can make the textArea (normal asp.net textbox with the mode set to multiline) display the HTML as it should look and not the code??

+1  A: 

you need a wysiwyg-editor like tinyMCE http://tinymce.moxiecode.com/

Schnalle
I am using NiceEdit, but the problem is on that page, because I am using Ajax Tabs, it is not showing the NiceEdit toolbar at all, what do you think is the problem?
Maen
are only the toolbars invisible, or is the editor not working at all?i don't know for sure what the issue is, but could it be that niceedit inits on onDomLoaded, and maybe it doesn't update after an ajax call. try to call bkLib.onDomLoaded(nicEditors.allTextAreas);after recieving results.
Schnalle
maybe there's a way to activate niceedit for single textareas. looking at the docs (http://wiki.nicedit.com/Javascript+API) i'd try something like:<pre><code>var myNicEditor = new nicEditor();myNicEditor.panelInstance('someElementID');</code></pre>
Schnalle
I found out there is something wrong with the ID in the script, I can't use the id of a text area directly, i had to write '<%= TextareaID.CurrentID %>' and now its working :P
Maen
+1  A: 

You can not display HTML result in TextArea/TextBox control. But to display HTML result you have many options.

As Schnalle said, best and the easy way to use an editor. Like tinyMCE or FCKEditor.

In a project I used a div to display and edit HTML content. It allows users to edit, copy, paste, make bold, make italic, .. etc. :

<div runat="server" ID="divContent" contenteditable="true"> 
    Editable Area, set your content here...
</ div>

Maybe you can combine textarea and div to do what you want.

Canavar