I made a button that if clicked, it would get the element ID of an HTML button which is "ContinueButton" and then it would invoke a click on it. Just as coded below. So basically, it will click this HTML button and it would eventually lead to the next HTML page.
private void button11_Click(object sender, EventArgs e)
{
webBrowser1.Document.GetElementById("ContinueButton").InvokeMember("Click");
Now, after the next HTML page has loaded, it contains a web form. This web form has an element ID by "secretnumber."
I made a code below and it should fill this web form.
webBrowser1.Document.GetElementById("secretnumber").SetAttribute("value", "320");
}
However, the program stopped and it didn't fill the web form ("secretnumber"). Please help me.
I added this code too but it didn't seem to work.
while (webBrowser1.ReadyState != WebBrowserReadyState.Complete)
{
Application.DoEvents();
}

Roger Williams3 reputationPosted Apr 15, 2012, 5:36 PM EDT
This is what I tried below, but it does not work
private void button11_Click(object sender, EventArgs e)
{
webBrowser1.Document.GetElementById("ContinueButton").InvokeMember("Click");
while (webBrowser1.ReadyState != WebBrowserReadyState.Complete)
{
Application.DoEvents();
}
webBrowser1.Document.GetElementById("secretnumber").SetAttribute("value", "320");
{
If button11 is clicked, it will automatically click an HTML Button with the element ID of "ContinueButton." Because "ContinueButton" is clicked, it would lead to the next html page. And in this next html page contains a web form with element ID of "secretnumber." I want that web form to be auto filled with "320" but it didn't fill it.
How can I make it wait for the next page to load and then automatically fill the web form with "320"?
Sam HobbsRank #107 · 20.5K reputationPosted Apr 15, 2012, 8:12 PM EDT
Do read my article Introduction to Web Site Scraping. It shows use of the DocumentComplete event.