Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

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">
    tinyMCE.init({
        mode: "textareas",
        theme: "simple",
        encoding: "xml"
    });
</script>


<textarea runat="server" id="txtareaTextActivity" name="content" cols="48" rows="5">  </textarea>
like image 551
PassionateDeveloper Avatar asked Apr 12 '11 13:04

PassionateDeveloper


1 Answers

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.

like image 65
Ravimallya Avatar answered Sep 18 '22 15:09

Ravimallya