How to make TinyMCE work inside an UpdatePanel?

前端 未结 12 960
别跟我提以往
别跟我提以往 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条回答
  •  猫巷女王i
    2021-02-07 13:39

    This solution no longer works for TinyMCE 4.2.3. Instead of using tinymce.mceRemoveControl() you now need to use tinymce.remove(). Here is a full working example:

    The Page

        <%@ Page Title="" Language="C#" MasterPageFile="~/MasterPages/Frame.master" AutoEventWireup="true" CodeFile="FullImplementation.aspx.cs" 
      Inherits="TinyMCE" ValidateRequest="false" %>
    
    
    
      
    
    
      
        
    
          
            Default editor text
          
    
          
            
               
               
            
          
    
                
    
        
      
    
      
    
    
    
    
    
    

    The Code-Behind:

        using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Net;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    
    public partial class TinyMCE : System.Web.UI.Page
    {
      protected void Page_Load(object sender, EventArgs e)
      {
        // we have to tell the editor to re-save the date on Submit 
        if (!ScriptManager.GetCurrent(Page).IsInAsyncPostBack)
        {
          ScriptManager.RegisterOnSubmitStatement(this, this.GetType(), "SaveTextBoxBeforePostBack", "SaveTextBoxBeforePostBack()");
        }
    
      }
    
      protected void butSaveEditorContent_Click(object sender, EventArgs e)
      {
        string htmlEncoded = WebUtility.HtmlEncode(tbHtmlEditor.Text);
    
      }
    
      private void SaveToDb(string htmlEncoded)
      {
        /// save to database column
      }
    
      protected void ddlTest_SelectedIndexChanged(object sender, EventArgs e)
      {
    
      }
    }
    

提交回复
热议问题