Search code examples
dotnetnuke-module

DotNetNuke 8.0.3 Html module Ckeditor removed after js validation


I have a HTML module (Ckeditor) in a custom module.

I have a RequiredFieldValidator that does the client validation on the editor. When the event validation fires, the HTML module dissapears. There isn't any Postback so we can't bind via the code-behind. If we do a postback the Ckeditor comes back.


Solution

  • I am also have same issue, but solved by using below method.

    Reason for this error, CK editor call 'destroy()' function when we click validate button. if we override that function then it will be fine.

    My Code

    <dnn:TextEditor ID="txtDescription" Width="100%" Height="200" runat="server" 
    HtmlEncode="True" DefaultMode="Rich" ChooseMode="False" ChooseRender="False" Mode="Rich" />
    
    <asp:Button ID="btnSave" runat="server" Text="Save" OnClick="btnSave_Click" 
    ValidationGroup="save" OnClientClick="editorsDestroy()" CssClass="btn btn-primary btn" />
    
    <script type="text/javascript"> 
    function editorsDestroy() 
    {
      try
      {
        CKEDITOR.instances.<%=txtDescription.ClientID%>_txtDescription.destroy=function(){ return true; }  
      } catch (ex) { alert(ex) }
    } 
    </script>