Hello,
I'm using a webbrowser control on a windows forms app. I'm calling the webbrowser control's navigate method in the form's load event to load a particular web page. In the webbrowser's DocumentCompleted event I need to implement some logic which will basically automate a login by using the html DOM. The automated login works fine, I tested that elseware, but its in this DocumentCompleted event that I want to implement it because it will need to occur not only on first page load but after periods of inactivity when the authentication times out I want to also automate the re-logon... in other words, when a session times out and a login is necessary the login page is automatcially loaded, so in this document completed event I will check to see if its the login page and if so, supply the credentials. I want to do this by testing for the existence of the html login controls... so I started with just a little sample code to test/confirm how I could do this check.... and it fires both the true and false code blocks of my 'if' statement?
HtmlElement UsernameElement;
UsernameElement = webBrowserControl.Document.GetElementById("LoginControl_UserName");
if (UsernameElement != null)
{
MessageBox.Show("username not null");
}
else
{
MessageBox.Show("username is null");
}
first I see the 'username is null' message, and then it also shows the 'username is not null' message? what the?