Quantcast
Channel: Visual C# forum
Viewing all articles
Browse latest Browse all 31927

Transfer the Winform Radio Button,check box data to Html Radio Button,check box

$
0
0

I am trying to implent send data from windows form Radio button , check box control to HTML Radio button , check box,

Scenario: My windows form in C# having various Radio button , check box and one submit button while click on the botton the Radio button , check box data is transfer to HTML Radio button , check box. (I dont want to use any 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>
Sex:<input id="radMale" type="radio" name="Sex" value="radMale" /><label for="radMale">
        Male</label>&nbsp;&nbsp;<input id="radFeMale" type="radio" name="Sex" value="radFeMale" /><label id="radFeMale">
        Female</label><br />
checkbox:<input id="chkboxP" type="checkbox" name="chkboxP" /><br /></body></html>

C# Winform Code

publicpartialclassForm1:Form{privateSHDocVw.InternetExplorerTargetIE=null;string url;publicForm1(){this.button1 =newSystem.Windows.Forms.Button();this.groupBox1 =newSystem.Windows.Forms.GroupBox();this.radioButton2 =newSystem.Windows.Forms.RadioButton();this.radioButton1 =newSystem.Windows.Forms.RadioButton();this.checkBox1 =newSystem.Windows.Forms.CheckBox();this.groupBox1.SuspendLayout();this.SuspendLayout();}privatevoid button1_Click(object sender,EventArgs e){GetTheIEObjectFromSystem("Q_26773800");SendTextToActiveElementWithSubmitOptionSet(false);}privatevoidGetTheIEObjectFromSystem(string inurl ="."){SHDocVw.ShellWindowsSWs=newSHDocVw.ShellWindows();foreach(SHDocVw.InternetExplorer internetExplorer inSWs){
            url = internetExplorer.LocationURL;TargetIE= internetExplorer;return;}}privatevoidSendTextToActiveElementWithSubmitOptionSet(bool btnSubmit){
        mshtml.IHTMLDocument2 document =null;
        document =TargetIE.Documentas mshtml.IHTMLDocument2;HTMLInputElement HTMLI;
        HTMLI = document.activeElement asHTMLInputElement;var tag = HTMLI.document as mshtml.HTMLDocumentClass;
        mshtml.IHTMLElementCollection hTMLElementCollection = tag.getElementsByTagName("input");foreach(mshtml.HTMLInputElement el in hTMLElementCollection){switch(el.id){case"radMale":if(radioButton1.Checked==true)
                        el.defaultChecked =true;else
                        el.defaultChecked =false;// el.defaultChecked = radioButton1.Checked;break;case"radFeMale":if(radioButton2.Checked==true)
                        el.defaultChecked =true;else
                        el.defaultChecked =false;// el.defaultChecked = radioButton2.Checked;break;}}}}

while click on button of winform it select the only first radio button that i select first time (ie when i select the male radio button from winform then that radio button get selected into html page but when i select female button from winform then click submit button html female radio button of html page is not selected.)

el.defaultcheck is not work properly but i already use the condition as required. so what i need to do so that when select the radio button in html page work properly


Viewing all articles
Browse latest Browse all 31927

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>