How to make TinyMCE work inside an UpdatePanel?

前端 未结 12 902
别跟我提以往
别跟我提以往 2021-02-07 13:28

I\'m trying to do something that many people seem to have been able to do but which I am unable to implement any solution. The TinyMCE control works pretty well in an asp.net fo

12条回答
  •  囚心锁ツ
    2021-02-07 14:03

    To execute the init everytime the UpdatePanel changes you need to register the script using ScriptManager:

    // control is your UpdatePanel
    ScriptManager.RegisterStartupScript(control, control.GetType(), control.UniqueID, "your_tinymce_initfunc();", true);
    

    NOTE: You cannot use exact mode on your init function, you can use either textareas or a class selector, or else it won't work properly.

    You also have to use

    ScriptManager.RegisterOnSubmitStatement(this, this.GetType(), "", "tinyMCE.triggerSave();");
    

    On a postback of a UpdatePanel the editor content isn't saved on the Textbox, because the default behavior is only for form.submit, so when you submit anything it will save the text before it posts.

    On the code behind to get the value you will just need to access TextBox.Text property.

    NOTE: If you are using the .NET GZipped you probably will have to drop it, I couldn't get it working, I had to remove this completely.

提交回复
热议问题