c# - Transfer the Winform Textbox data to Html Textbox -


i trying implent send data windows form text box control html text box,

scenario: windows form in c# having various textbox control , 1 submit button while click on botton textbox data transfer html tetxtboxes. (i dont want use query string etc)

my html code

<!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head>     <title>test application</title>     <script type="text/javascript" language="javascript">         window.onload = body_onload;         function body_onload() {             document.getelementbyid("txtfirstname").focus();         }     </script> </head> <body>     first name:     <input type="text" id="txtfirstname" /><br />     last name:     <input type="text" id="txtlastname" /><br />     address:     <input type="text" id="txtaddress" /><br />     mobile:     <input type="text" id="txtmobile" /><br /> </body> </html> 

c# winform code

public partial class form1 : form     {         private shdocvw.internetexplorer targetie = null;         string url;         public form1()         {         this.button1 = new system.windows.forms.button();         this.textbox1 = new system.windows.forms.textbox();         this.textbox2 = new system.windows.forms.textbox();         this.textbox3 = new system.windows.forms.textbox();         this.textbox4 = new system.windows.forms.textbox();         }          private void button1_click(object sender, eventargs e)         {             gettheieobjectfromsystem("q_26773800");             sendtexttoactiveelementwithsubmitoptionset(false);         }         private void gettheieobjectfromsystem(string inurl = ".")         {             shdocvw.shellwindows sws = new shdocvw.shellwindows();             foreach (shdocvw.internetexplorer internetexplorer in sws)             {                 url = internetexplorer.locationurl;                 targetie = internetexplorer;                 return;             }          }         private void sendtexttoactiveelementwithsubmitoptionset(bool btnsubmit)         {             mshtml.ihtmldocument2 document = null;             document = targetie.document mshtml.ihtmldocument2;             if (!document.activeelement.istextedit)             {                 messagebox.show("active element not text-input system");             }             else             {                 htmlinputelement htmli;                 //htmli = document.activeelement htmlinputelement;                   htmli = document.activeelement htmlinputelement;                  var tag = htmli.document mshtml.htmldocumentclass;                  mshtml.ihtmlelementcollection = tag.getelementsbytagname("input");                  (int = 0; i< a.length; i++) // a.length = 4                  {                   }                 htmli.value = textbox1.text;              }         }     } } 

using code first winform textbox value passess html textbox want transfer values other textxbox winform textbox html textbox.

using loop length = 4 dont know how use loop transfer data winform html?

just paste code add function

sendtexttoactiveelementwithsubmitoptionset(bool btnsubmit)  

i solve issue below code

 private void sendtexttoactiveelementwithsubmitoptionset(bool btnsubmit)         {             mshtml.ihtmldocument2 document = null;             document = targetie.document mshtml.ihtmldocument2;             if (!document.activeelement.istextedit)             {                 messagebox.show("active element not text-input system");             }             else             {                 htmlinputelement htmli;                 htmli = document.activeelement htmlinputelement;                 var tag = htmli.document mshtml.htmldocumentclass;                 mshtml.ihtmlelementcollection htmlelementcollection = tag.getelementsbytagname("input");                     foreach (mshtml.htmlinputelement el in htmlelementcollection)                     {                         switch (el.id)                         {                             case "txtfirstname":                                 el.value = textbox1.text;                                 break;                             case "txtlastname":                                 el.value = textbox2.text;                                 break;                             case "txtaddress":                                 el.value = textbox3.text;                                 break;                             case "txtmobile":                                 el.value = textbox4.text;                                 break;                         }                                             }             }         } 

Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -