tinymce get HTML code when postback

前端 未结 8 682
醉话见心
醉话见心 2020-12-18 06:26

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

 \"

相关标签:
8条回答
  • 2020-12-18 07:07

    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
    
    0 讨论(0)
  • 2020-12-18 07:08

    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.

    0 讨论(0)
  • 2020-12-18 07:09

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

    0 讨论(0)
  • 2020-12-18 07:09

    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.

    0 讨论(0)
  • 2020-12-18 07:10

    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.

    0 讨论(0)
  • 2020-12-18 07:17

    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.

    0 讨论(0)
提交回复
热议问题