Submitting a form in Axwebbrowser in asp.net

Source: Internet
Author: User
asp.net|web| Submit Form <tr bgcolor= #ffffff width= "100%" >
&LT;TD Align=middle colspan=2>
<form id= "Form1" >
<input language=javascript Class=button Id=btton style= "border-top-style:groove; Border-right-style:groove; Border-left-style:groove; Border-bottom-style:groove "Type=submit value=" "Start" name=btton></td></tr>
</form>


<input type= "button" id= "Button1" >


-----------------------------------------------------------------------------------
Form1.cs


Using System;
Using System.Drawing;
Using System.Collections;
Using System.ComponentModel;
Using System.Windows.Forms;
Using System.Data;
Using Mshtml;


Namespace WindowsApplication2
{
<summary>
Summary description of the Form1.
</summary>
public class Form1:System.Windows.Forms.Form
{
Private Axshdocvw.axwebbrowser AxWebBrowser1;
Private System.Windows.Forms.Button button1;
Private System.Windows.Forms.Button button2;
<summary>
The required designer variable.
</summary>
Private System.ComponentModel.Container components = null;


Public Form1 ()
{
//
Required for Windows Forms Designer support
//
InitializeComponent ();


//
TODO: Add any constructor code after the InitializeComponent call
//
}


<summary>
Clean up all resources that are in use.
</summary>
protected override void Dispose (bool disposing)
{
if (disposing)
{
if (Components!= null)
{
Components. Dispose ();
}
}
Base. Dispose (disposing);
}


Code generated #region the Windows forms Designer
<summary>
Designer supports required methods-do not use the Code editor to modify
The contents of this method.
</summary>
private void InitializeComponent ()
{
System.Resources.ResourceManager resources = new System.Resources.ResourceManager (typeof (Form1));
This.axwebbrowser1 = new Axshdocvw.axwebbrowser ();
This.button1 = new System.Windows.Forms.Button ();
This.button2 = new System.Windows.Forms.Button ();
((System.ComponentModel.ISupportInitialize) (This.axwebbrowser1)). BeginInit ();
This. SuspendLayout ();
//
AxWebBrowser1
//
This.axWebBrowser1.Enabled = true;
This.axWebBrowser1.Location = new System.Drawing.Point (80, 184);
This.axWebBrowser1.OcxState = ((System.Windows.Forms.AxHost.State) (resources. GetObject ("Axwebbrowser1.ocxstate"));
This.axWebBrowser1.Size = new System.Drawing.Size (300, 150);
This.axWebBrowser1.TabIndex = 0;
//
Button1
//
This.button1.Location = new System.Drawing.Point (160, 96);
This.button1.Name = "Button1";
This.button1.Size = new System.Drawing.Size (88, 24);
This.button1.TabIndex = 1;
This.button1.Text = "Button1";
This.button1.Click + = new System.EventHandler (This.button1_click);
//
Button2
//
This.button2.Location = new System.Drawing.Point (304, 96);
This.button2.Name = "Button2";
This.button2.TabIndex = 2;
This.button2.Text = "Button2";
This.button2.Click + = new System.EventHandler (This.button2_click);
//
Form1
//
This. AutoScaleBaseSize = new System.Drawing.Size (6, 14);
This. ClientSize = new System.Drawing.Size (584, 397);
This. Controls.Add (This.button2);
This. Controls.Add (This.button1);
This. Controls.Add (This.axwebbrowser1);
This. Name = "Form1";
This. Text = "Form1";
((System.ComponentModel.ISupportInitialize) (This.axwebbrowser1)). EndInit ();
This. ResumeLayout (FALSE);


}
#endregion


<summary>
The main entry point for the application.
</summary>
[STAThread]
static void Main ()
{
Application.Run (New Form1 ());
}


private void Button1_Click (object sender, System.EventArgs e)
{
object x = System.Reflection.Missing.Value;
Axwebbrowser1.navigate (@ "E:\Documents and settings\administrator\ desktop \dddd.htm", ref x, ref x, ref x, ref x);
}


private void Button2_Click (object sender, System.EventArgs e)
{
Mshtml. IHTMLDocument2 doc = (mshtml. IHTMLDocument2) axwebbrowser1.document;
Mshtml. IHTMLFormElement f1 = (mshtml. ihtmlformelement) Doc.all.item ("Form1", 0);
(MSHTML. IHTMLFormElement) (F1)). Submit ();
Mshtml. IHTMLElement Element = (mshtml. IHTMLElement) Doc.all.item ("Button1", 0);
Element.click ();
}
}
}




Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.