I have the following:
protected static void GetWebPageWorker()
{
using (WebBrowser browser = new WebBrowser())
{
// browser.ClientSize = new Size(_width, _height);
browser.ScrollBarsEnabled = false;
browser.ScriptErrorsSuppressed = true;
browser.Navigate(_url);
// Wait for control to load page
while (browser.ReadyState != WebBrowserReadyState.Complete)
Application.DoEvents();
//Insert the search term in to the input textfield
browser.Document.GetElementById(search_div_id).OuterText = search_term;
//Click on the search button (POST request)
browser.Document.GetElementById(search_button_id).InvokeMember("Click");
//This didn't work
//browser.Update();
while (browser.ReadyState != WebBrowserReadyState.Complete)
Application.DoEvents();
//PROBLEM this is returning the original HTML before POST
//and not the HTML from the web page after the POST.
html = browser.DocumentText;
}
}
it inserts a value to search for in a HTML element and then clicks the search button and the POST is done. However the WebBrowser object doesn't seem to refresh its DocumentText property so that I can return the HTML of the page after the search button has been clicked.
How can I fix this?