I'm having issues with a browser control in a windows form. I've searched for waiting for a page to fully load, but it seems to want to fire off before the page loads anyway. Here is the code:
private void loginToML()
{
string userName = Globals.SCMAddin.getUserName();
string userPassword = Globals.SCMAddin.getUserPassword();
try
{
HtmlDocument doc = browser_Window.Document;
doc.GetElementById("ctl00_ctl00_cphNestedUtility_cphLeft1_ctlValidateUser_ctl00_txtUserid").SetAttribute("value", userName);
doc.GetElementById("ctl00_ctl00_cphNestedUtility_cphLeft1_ctlValidateUser_ctl00_btnValidate").InvokeMember("click");
waitforIE();
doc = browser_Window.Document;
doc.GetElementById("ctl00_ctl00_cphNestedUtility_cphLeftContent_ctlValidateUser_ctl00_txtPassword").SetAttribute("value", userPassword);
doc.GetElementById("ctl00_ctl00_cphNestedUtility_cphLeftContent_ctlValidateUser_ctl00_btnContinue").InvokeMember("click");
waitforIE();
this.loggedIn = true;
}
catch (Exception loginError)
{
throw new Exception("Error Logging In");
}
}//END LOGINTOML
private void waitforIE()
{
while (browser_Window.ReadyState != WebBrowserReadyState.Complete)
{
Application.DoEvents();
}
}//END WAITFORIE
The website to login to is https://olui2.fs.ml.com/login/login.aspx
I had this working in Excel VBA, but I've been transferring most of my code over to an Excel Add-In.