How to make TinyMCE work inside an UpdatePanel?

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

    Ok, your problem is two fold. Stefy supplied you with part of the answer, which is you have to initialize TinyMCE on the postback by registering startup script like so:

    using System.Web.UI;
    
    namespace TinyMCEProblemDemo
    {
        public partial class EditorClean : UserControl
        {
            protected void Page_Load(object sender, System.EventArgs e)
            {                
                  ScriptManager.RegisterStartupScript(this.Page, 
                      this.Page.GetType(), mce.ClientID, "callInt" + mce.ClientID + "();", true);
            }
        }
    }
    

    The second problem you have is with your implementation of a custom control. Designing custom controls is out of scope of this answer. Google can help you there.

    You have multiple instances of your control on the page which can cause you issues with script, as it get rendered multiple times. This is how I modified your markup to solve your issue(notice dynamic naming of your script functions, custom controls should be self contained and mode: "exact" on the tinyMCE.init):

    <%@ Control Language="C#" AutoEventWireup="true" CodeBehind="EditorClean.ascx.cs"
        Inherits="TinyMCEProblemDemo.EditorClean" %>
    
    
    
    
    

提交回复
热议问题