tinymce get HTML code when postback

I have the tinymce -control as a WYSIWYG-Editior in my asp.net page.

When I have e.g. a Text in Bold, after the Postback it is shown as


in the textarea instead of the bolded text.

Any ideas?

My code:

    <script type="text/javascript" src="../scripts/tiny_mce/tiny_mce.js"></script>
<script type="text/javascript">
        mode: "textareas",
        theme: "simple",
        encoding: "xml"

<textarea runat="server" id="txtareaTextActivity" name="content" cols="48" rows="5">  </textarea>


Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

I also had the same problem. But fixed it by decoding the textarea text each time in page load in c# as below:

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

I’m using encoding: "xml" in tinymce init function. .net version 4.5.1.

Hope it helps someone.

Method 2

You can use this code for solving your problem:

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

I found it in this post : https://stackoverflow.com/a/8029637/1509986

If you get some security errors you can use


in your page.

Method 3

This happens when the editor control in placed within Update Panel.
Try to remove update panel and check. It worked for me.

Method 4

After hours and hours of search, there is no way of this, it’s an unsolved bug until now.
So I had to switch to another WYSIWYG-Editor.

Method 5

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

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


Hope this helps.

Method 6

Step 1:
in TinyMCE Configuration use

encoding: "xml",

Step 2: in Java Script
after init the TinyMCE use this code, where ‘textarea.RichText’ is the class selector for the text area

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

Step 3 : in Server code, when setting the value of the text area , decode the text first
For example in ASP.net use
textarea.text = HttpUtility.HtmlDecode(Source)

Method 7

i have same problem.for fix it you mast add script code for element create post back . my button create post back,I add it OnClientClick() :

<asp:LinkButton ID="lbnSave" OnClick="lbnSave_Click" ToolTip="Add New" OnClientClick="dotim()"

and script is:
function dotim() {
      } // this is my attempt at a fix

Method 8

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

<script type="text/javascript">
        mode: "textareas",
        theme: "simple",
        encoding: ""

This is default setting, and worked in my case. See documentation on this page http://www.tinymce.com/wiki.php/Configuration3x:encoding

All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Notify of

Inline Feedbacks
View all comments
Would love your thoughts, please comment.x