0
votes

I'm working on an old ASP.NET WebForms project using CKEditor 4. Due to security reasons, I have CKEditor set to Html encode all output. However, I'm noticing that if the textarea has default text provided by the application, unless I go into the textarea and change something, CKEditor doesn't seem to encode the value. So if I do something to cause a postback, like attempting to save the record after page load, I get the nasty page validation error from .NET.

Is there a way to trick ckeditor into thinking the editor has been modified so that it encodes the HTML? Or better solution?

Thanks

1

1 Answers

0
votes

I solved my issue by detecting ASP.NET postback and forcing an update of the editor value using setData

$('input[type="submit"], button[type="submit"], a[href*="__doPostBack"]').on('click', function () {
    $instance.setData($editor.html());
});

Doesn't seem to be the nicest of ways, but it does work.

Correction, that appeared to work but only on initial load. This seems to be working:

$instance.on('instanceReady', function () {
    $instance.updateElement();
});