0

I've created an application that grabs data from a web page and saves them to a database. This pages sends some __postbacks. After the postback the page loads some data that I need to save. I do not know how to detect this event so I've created a button which grabs the data when pressed by the user. How can I automate the process so that the user won't have to check for the postback himself? That is how can I detect the postback event in my webbrowser control?

pzogr
  • 424
  • 1
  • 12
  • 30

1 Answers1

1

The webbrowser control has a DocumentCompleted event. You can use the WebBrowser.Document property to look for something specific in this event.

private void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e) {
  if (webBrowser1.Document.Body.InnerHtml.Contains("some way that I know I am ready"))
  }
aquinas
  • 23,318
  • 5
  • 58
  • 81
  • Thanks for the answer... I did not realize that the DocumentCompleted event would fire but I checked it and it fired 4 times! So I guess I'll have to check for the data every time which is not very hard to implement. Do you know of another way? What about the original question - can I detect the postback event somehow? – pzogr Jul 18 '12 at 18:07
  • I don't think that's possible with the webbrowser control. – aquinas Jul 18 '12 at 18:21
  • it fired 4 times! >> For all 4 times `WebBrowser.ReadyState` would be different and you might need to process only when the status is `WebBrowserReadyState.Complete` – Sen Jacob May 11 '18 at 14:24