For our WebBrowser automatic guidance, or even to submit features, is not difficult.
Suppose there is a simple login page, enter the user name password, click "Login" button to login. Known user name input box id (or Name, the same below) is the username, the password input box id is the password, "login" button id is submitbutton, then we only need webBrowser the DocumentCompleted event use the following code that is may:
HtmlElement btnSubmit = webBrowser.Document.All["submitbutton"];
HtmlElement tbUserid = webBrowser.Document.All["username"];
HtmlElement tbPasswd = webBrowser.Document.All["password"];
if (tbUserid == null || tbPasswd == null || btnSubmit == null)
return;
tbUserid.SetAttribute("value", "smalldust");
tbPasswd.SetAttribute("value", "12345678");
btnSubmit.InvokeMember("click");
Here we use the SetAttribute to set the text box "value" attribute, with InvokeMember to call the button "click" method. Html for the different elements of their own properties and methods are also different, so. Net 2.0 provides a unified HtmlElement to summarize the various elements of the same Html provides two ways to call the element-specific functionality. Html elements on the various properties and methods list, you can access MSDN's DHTML Reference.
※ submitted on the form, indeed there is another way to access form elements instead of button, and submit with the form element methods:
HtmlElement formLogin = webBrowser.Document.Forms["loginForm"];
formLogin.InvokeMember("submit");
breast[
^]