tinymce get HTML code when postback

廉价感情. 提交于 2019-11-29 07:33:04

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.

Alex

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

validateRequest="false"

in your page.

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

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.

Sanaa

Try passing your js code to the 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.

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

tinymce.init(TMCEconfig);

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

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)

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()"
                            runat="server">save</asp:LinkButton>

and script is:

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

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

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

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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!