title: webBrowser elements not populating in revised code
body: <p>I am rewriting a large portion of my program and have run into something that makes no since to me at all.</p>
  
  <p>The first block of code works perfectly.  The web page opens in the webBrowser control.  The username field populates, as well as the password field.  And the button clicks without any issue.</p>
  
  <pre><code>using System;
  using System.IO;
  using System.Collections.Generic;
  using System.ComponentModel;
  using System.Data;
  using System.Drawing;
  using System.Linq;
  using System.Text;
  using System.Net;
  using System.Threading;
  using System.Windows.Forms;
  using System.Runtime.InteropServices;
  
  namespace TimeClockEntry2
  {
      public partial class PNow : Form
      {
          int linkcount = 0;
          string userName;
          string passWord;
  
          public PNow()
          {
              InitializeComponent();
  //            ControlBox = false;  // This line hides the Minimize, Maximize, and Close buttons
              webBrowser1.Navigate("https://ew23.ultipro.com/login.aspx");
          }
  
          private void PNow_Load(object sender, EventArgs e)
          {
              this.WindowState = FormWindowState.Normal;
              userName = Properties.Settings.Default.userName;
              passWord = Properties.Settings.Default.passWord;
          }
  
          private void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
          {
              linkcount++;
  
              if (linkcount == 1)
              {
                  webBrowser1.Document.GetElementById("ctl00_Content_Login1_UserName").SetAttribute("Value", userName);
                  webBrowser1.Document.GetElementById("ctl00_Content_Login1_Password").SetAttribute("value", passWord);
                  webBrowser1.Document.GetElementById("ctl00_Content_Login1_LoginButton").InvokeMember("click");
              }
  
          }
      }
  }
  </code></pre>
  
  <p>The second block of code opens the web page and then stops.  Nothing else happens.</p>
  
  <p>Any ideas would be awesome, thank you.</p>
  
  <pre><code>using System;
  using System.IO;
  using System.Collections.Generic;
  using System.ComponentModel;
  using System.Data;
  using System.Drawing;
  using System.Linq;
  using System.Text;
  using System.Net;
  using System.Threading;
  using System.Windows.Forms;
  using System.Runtime.InteropServices;
  
  namespace TimeClockEntry3
  {
      public partial class PNow : Form
      {
          int linkcount = 0;
          string userName;
          string passWord;
  
          public PNow()
          {
              InitializeComponent();
  //            ControlBox = false;  // This line hides the Minimize, Maximize, and Close buttons
              webBrowser1.Navigate("https://ew23.ultipro.com/login.aspx");
          }
  
          private void PNow_Load(object sender, EventArgs e)
          {
              this.WindowState = FormWindowState.Normal;
              userName = Properties.Settings.Default.USERNAME;
              passWord = Properties.Settings.Default.PASSWORD;
  
              //MessageBox.Show(userName);
              //MessageBox.Show(passWord);
          }
  
          private void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
          {
              linkcount++;
  
              if (linkcount == 1)
              {
                  webBrowser1.Document.GetElementById("ctl00_Content_Login1_UserName").SetAttribute("Value", userName);
                  webBrowser1.Document.GetElementById("ctl00_Content_Login1_Password").SetAttribute("value", passWord);
                  webBrowser1.Document.GetElementById("ctl00_Content_Login1_LoginButton").InvokeMember("click");
              }
          }
      }
  }
  </code></pre>