8

I navigated to a website with a form that has no submit button but does have form. I would like to submit this form. How to do this using C# and WebBrowser control?

abatishchev
  • 98,240
  • 88
  • 296
  • 433
Tom Smykowski
  • 25,487
  • 54
  • 159
  • 236
  • you can do it with javascript? Im not sure about C# because in code behind I believe you would have to have that submit button to refer to in order to submit the form – TStamper Oct 08 '09 at 19:06
  • You can do this in code without using a WebBrowser. http://stackoverflow.com/questions/793755/how-to-fill-forms-and-submit-with-webclient-in-c –  Oct 08 '09 at 19:22
  • Did InvokeMember work for you? – Cam Soper Oct 08 '09 at 20:02

1 Answers1

9

Try this (or something like it):

HtmlElementCollection elements = this.webBrowserControl.Document.GetElementsByTagName("Form");  

foreach(HtmlElement currentElement in elements)
{
    currentElement.InvokeMember("submit");
}
Corv1nus
  • 4,523
  • 1
  • 26
  • 37
Cam Soper
  • 1,499
  • 9
  • 10