I have multiple
<asp:TextBox TextMode="MultiLine">
elements on a webpage. Initially, I populate them using VB code behind and then convert them into TinyMCE editors with the help of the jQuery TinyMCE plugin. Each text box has an associated button for submitting the text back to the code behind for insertion into a database.
Upon clicking the submit button, I realized that I needed to "save" the editor's contents to the text box before proceeding further. However, even after completing this step, the edits were not being reflected in the code behind.
My approach involves utilizing jQuery. Below is the click handler implementation as all buttons are considered submit buttons in ASP.NET due to the submit
class:
$('input.submit').live('click', function() {
tinyMCE.EditorManager.triggerSave();
});
Hence, whenever any submit button is clicked, the save event is triggered for all TinyMCE editors. Upon execution, I verified the edited content by checking the textarea value using JavaScript:
console.log($(this).parent().find('textarea').val());
However, despite seeing the edits through console.log in Chrome Developer tools, none of the changes were visible in the server-side click handler for the submit button:
Dim paragraph As String = Me.myTextArea.Text
' This retrieves the original text, not the edited version
Additional Information:
- Each editor resides within its own update panel
- Due to the HTML content being submitted, I had to disable
EnableEventValidation="false"
andValidateRequest="false"
(based on advice from a senior developer in our team) - While I'm relatively new to .NET, this inconsistent behavior appears perplexing to me. There might be a crucial aspect that I am overlooking.