Tinymce get html code after postback

I have tinymce -control as WYSIWYG-Editior on my asp.net page.

When I have, for example, the Text is in bold, after the postback it is displayed as

"<p><strong>asd</strong></p>" 

in the text box instead of bold text.

Any ideas?

My code is:

  <script type="text/javascript" src="../scripts/tiny_mce/tiny_mce.js"></script> <script type="text/javascript"> tinyMCE.init({ mode: "textareas", theme: "simple", encoding: "xml" }); </script> <textarea runat="server" id="txtareaTextActivity" name="content" cols="48" rows="5"> </textarea> 
+5
tinymce postback
source share
8 answers

After hours and hours of searching, there is no way to do this; this is an unresolved error so far. So I had to switch to another WYSIWYG editor.

0
source share

I also had the same problem. But fixed it by decoding textarea text every time a page is loaded in C #, as shown below:

  protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { // Some stuff } txtDescription.Text = HttpUtility.HtmlDecode(txtDescription.Text); } 

I am using encoding: "xml" in the tinymce..net version 4.5.1 initialization function.

Hope this helps someone.

+3
source share

You can use this code to solve your problem:

TextAreaID.Text = Server.HtmlDecode("<p>hello</p>");

I found it in this post: fooobar.com/questions/880062 / ...

If you get some security errors, you can use

 validateRequest="false" 

On the page.

+2
source share

This occurs when the editor control is placed in the update panel. Try removing the update panel and checking. It worked for me.

+2
source share

Try passing your js code to ScriptManager. Worked for me.

 string script = "alert('something')"; ScriptManager.RegisterClientScriptBlock(UpdatePanelSend, typeof(UpdatePanel), "jscript", script, true); 

http://snippets.dzone.com/posts/show/6725

Hope this helps.

0
source share

Step 1: in TinyMCE configuration use

 encoding: "xml", 

Step 2: in Java Script after initialization, TinyMCE uses this code, where "textarea.RichText" is the class selector for the text area

 tinymce.init(TMCEconfig); // Fix Html Decodeing $('textarea.RichText').each(function () { var $this = $(this); var x = $this.text(); $this.html(x) }); 

Step 3: in the server code, when setting the value of the text area, first decode the text For example, in ASP.net use

 textarea.text = HttpUtility.HtmlDecode(Source) 
0
source share

I have the same problem. For correction, you can add script code for the create post back element. my button creates the message back, I add it to OnClientClick ():

 <asp:LinkButton ID="lbnSave" OnClick="lbnSave_Click" ToolTip="Add New" OnClientClick="dotim()" runat="server">save</asp:LinkButton> 

and script:

 function dotim() { tinyMCE.triggerSave(); } // this is my attempt at a fix 
0
source share

Change the init function and set the encoding to an empty string.

 <script type="text/javascript"> tinyMCE.init({ mode: "textareas", theme: "simple", encoding: "" }); </script> 

This is the default value and works in my case. See the documentation on this page http://www.tinymce.com/wiki.php/Configuration3x:encoding

-one
source share

All Articles