views:

95

answers:

2

I have a standard ASP.NET web form in a web page, and this page is hosted in a .NET Winform with a WebBrowser Control. Using c# how do I control the WebBrowser Control to submit the ASP.NET form? (eg somehow "clicking" on the button from the Winform?)

Update: to complicate things we have the ASP.NET validators which seem to make simple document.forms(0).submit() not work

+1  A: 

I answered a similar question. Check this : simulate Web Page keystroke

You can use the following code

WebBrowser1.Document.Forms("loginform").InvokeMember("submit");
Shoban
Thanks, almost worked, but the ASP.NET validators stop you from directly calling form.submit()
Matthew Lock
May be you missed to fill in any form fields?
Shoban
I think that the validators actually stop the form.submit event from firing as you get no message saying fields aren't filled out like you would when you press the button normally.
Matthew Lock
A: 

Because of the complication of the ASP.NET validators somehow messing with the normal form.submit() flow the submit button's click method had to be called:

WebBrowser1.Document.getElementById("mybutton").InvokeMember("click");
Matthew Lock