title: How to click a button on an ASP.NET web page programmatically?
body: <p>I am trying to figure out how to click a button on a web page programmatically.</p>
  
  <p>Specifically, I have a WinForm with a WebBrowser control.  Once it navigates to the target ASP.NET login page I'm trying to work with, in the DocumentCompleted event handler I have the following coded:</p>
  
  <pre><code>HtmlDocument doc = webBrowser1.Document;
  
  HtmlElement userID = doc.GetElementById("userIDTextBox");
  userID.InnerText = "user1";
  
  HtmlElement password = doc.GetElementById("userPasswordTextBox");
  password.InnerText = "password";
  
  HtmlElement button = doc.GetElementById("logonButton");
  button.RaiseEvent("onclick");
  </code></pre>
  
  <p>This fills the userid and password text boxes fine, but I am not having any success getting that darned button to click; I've also tried "click", "Click", and "onClick" -- what else is there?.  A search of msdn of course gives me no clues, nor groups.google.com.  I gotta be close.  Or maybe not -- somebody told me I should call the POST method of the page, but how this is done was not part of the advice given. </p>
  
  <p>BTW The button is coded:</p>
  
  <pre><code>&lt;input type="submit" name="logonButton" value="Login" onclick="if (typeof(Page_ClientValidate) == 'function') Page_ClientValidate(); " language="javascript" id="logonButton" tabindex="4" /&gt;
  </code></pre>