How to make TinyMCE work inside an UpdatePanel?

前端 未结 12 944
别跟我提以往
别跟我提以往 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 13:44

    This is an old question, but after hours searching and messing around looking for the answer, I feel obligated to post the solution I came up with.

    It appears that, at least in the implementation I'm using (multiple editors inside an UpdatePanel) that tinyMCE must be informed the control is going away when the UpdatePanel submits, or else it will refuse to load it again.

    So, in addition to the code to Init TinyMCE (which only needs to run when the whole page loads) you need to do this for each of your MCE textboxes:

    ScriptManager.RegisterStartupScript(this, this.GetType(), elm1.UniqueID+"Add",
        "tinyMCE.execCommand('mceAddControl', true,'" + elm1.ClientID + "');", true);
    ScriptManager.RegisterOnSubmitStatement(this, this.GetType(), elm1.UniqueID + "Remove",
        "tinyMCE.execCommand('mceRemoveControl', true,'" + elm1.ClientID + "');");
    

    elm1 is whatever the tinyMCE element is. Mine is a textarea residing in a UserControl, but you can apply it to any item you want to bind/unbind your textarea.

提交回复
热议问题