Webbrowser control: auto fill, only works one time, why?

Posted by Khou on Stack Overflow See other posts from Stack Overflow or by Khou
Published on 2010-03-26T00:42:36Z Indexed on 2010/03/26 1:13 UTC
Read the original article Hit count: 679

Filed under:
|
|

The following code loads a page and auto fills in the values.

private void button1_Click(object sender, EventArgs e)
{

//Load page and autofill
webBrowser1.Navigate("http://exampledomain.com");
webBrowser1.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(autoFillDetails);
// etc...etc..
}


private void autoFillDetails(object sender, WebBrowserDocumentCompletedEventArgs e)
{
// do auto fill values
((WebBrowser)sender).Document.GetElementById("MY_NAME").SetAttribute("value", "theMynamevalue");
// etc...etc...

}

Autofill only work one time! After the form has been submitted, and you navigate back to the page previous form page (even when you click the button again), it will no longer auto fill the form values!

Note: The the "autoFillDetails" code is executed a second time, 3rd time etc, it still would not auto fill the values. why does it only work one time? what am i doing wrong?

© Stack Overflow or respective owner

Related posts about c#

Related posts about webbrowser-control