I've the below javascript code for inserting the html text at the current cursor location.
function insertTextInHTMLEditorAtCursor() {
var editorControl = document.getElementById("Editor1");
var editPanel = editorControl.control.get_editPanel();
if (editPanel.get_activeMode() == 0) {
var designPanel = editPanel.get_activePanel(); // Achievable till here
designPanel.insertHTML("Additional text"); // C# equivalent?
}
}
The above code does the job perfectly fine by using Javascript.
However, my requirement is to achieve the same using code behind (not by using JS).
So far I achieved writing the C# equivalent code using Reflection till the line with the comment "Achievable till here". Below is the C# code:
PropertyInfo piEditPanel = this.testEditor.GetType().GetProperty(
"EditPanel",
System.Reflection.BindingFlags.NonPublic |
System.Reflection.BindingFlags.Static |
System.Reflection.BindingFlags.Instance);
var editPanel = piEditPanel.GetValue(this.testEditor, null);
PropertyInfo piActiveMode = piEditPanel.PropertyType.GetProperty("ActiveMode");
dynamic designMode = piActiveMode.GetValue(editPanel, null);
FieldInfo fiModelPanel = piEditPanel.PropertyType.GetField("ModePanels",
BindingFlags.Static |
BindingFlags.NonPublic |
BindingFlags.Instance);
dynamic modePanels = fiModelPanel.GetValue(editPanel);
var designModel = modePanels[0]; // I get the DesignPanel
I'm stuck at the next following line - the reason being insertHTML method is not defined in any of the .cs files (I downloaded the AJAX Control toolkit source code to check this). It is rather defined as a Javascript function in DesignPanel.pre.js file.
My question: Is there a way that I can "somehow" be able to call the insertHTML method?
Thanks in advance.