javascript - Getting and Setting CKEditor HTML in a C#.net Winform App -


i trying use ckeditor in winform app load, manipulate, , store html content in sql server database.

i found great post on how ckeditor onto winform:

can ckeditor used in winforms application (x)html editing?

however not detail how load html content or extract once user has manipulated it.

i have tried:

webbrowser1.document.getelementbyid("editor1").innertext;

however returns initial data loaded editor, after manipulated user, still returns same value.

if expand on answer in link above code loads editor content , code displays message box in winform application current content, appreciate it. suspicion requires more javascript in html file opened know nothing javascript , i've spent several days trying trip way through no success.

thanks in advance.

in more research today, able answer own question... blank html setup file load webbrowser control looks this:

<html>     <head>         <script src="http://cdn.ckeditor.com/4.4.7/full/ckeditor.js"></script>     </head>     <script>         var editor1, html = '';          function createeditor() {             if ( editor1 )                 return;              // create new editor instance inside <div id="editor1"> element,             // setting value html.             var config = {};             editor1 = ckeditor.appendto( 'editor1', config, html );         }          function gethtml() {             if ( !editor1 )                 return;             html = editor1.getdata();             return html          }          function sethtml(vshtml) {             if ( !editor1 )                 return;             editor1.setdata(vshtml)         }     </script>     <div id="editor1"></div> </html> 

the c# code looks this:

using system; using system.collections.generic; using system.componentmodel; using system.data; using system.drawing; using system.linq; using system.text; using system.threading.tasks; using system.windows.forms;  namespace htmleditor {     public partial class form1 : form     {         public form1()         {             initializecomponent();         }          private void form1_load_1(object sender, eventargs e)         {             webbrowser1.navigate("c:\\amresearch\\htmleditor\\blank.html");             application.doevents();         }          private void button1_click_1(object sender, eventargs e)         {             webbrowser1.document.invokescript("createeditor");         }          private void button2_click(object sender, eventargs e)         {             string shtml;             shtml = (string)webbrowser1.document.invokescript("gethtml");             messagebox.show(shtml);         }          private void button3_click(object sender, eventargs e)         {             object[] objarray = new object[1];             objarray[0] = "<p>hellow world!</p>";             webbrowser1.document.invokescript("sethtml", objarray);         }      } } 

Comments

Popular posts from this blog

java - Andrioid studio start fail: Fatal error initializing 'null' -

android - Gradle sync Error:Configuration with name 'default' not found -

StringGrid issue in Delphi XE8 firemonkey mobile app -