views:

88

answers:

2

How can I create a program with C# to submit the form(in the web browser CONTROL in windows Apps)automaticlly ?

+3  A: 

The WebBrowser control has a Document property, which returns an HtmlDocument. The HtmlDocument has several members you can use to traverse and manipulate the DOM.

Once you've used these methods to find the form, you can use InvokeMember to call the form's submit method.

If you know the page has a single form:

foreach (HtmlElement form in webBrowser1.Document.Forms)
    form.InvokeMember("submit");

If you know the ID of the form you would like to submit:

HtmlElement form = webBrowser1.Document.GetElementById("FormID");
if (form != null)
    form.InvokeMember("submit");
meagar
A: 

i googled "run javascript winform" and found this

Looks helpful.

ps
This method only works if there is a function that submits the form defined in the page. So usually this won't work unless the page was created by the same author of the WinForms app.
Jon Seigel
Ok.How about setting the addressbar value to "javascript:document.forms["myform"].submit();" after the page is loaded.
ps
Try it and find out?
Jon Seigel