title: How to execute a Javascript function from a C# WebBrowser?
body: <p>I'm doing some web automation via C# and a WebBrowser. There's a link which I need to 'click', but since it fires a Javascript function, apparently the code needs to be executed rather than just having the element clicked (i.e. element.InvokeMember("click")). Here's the href for the element, which opens an Ajax form:</p>
  
  <pre><code>javascript:__doPostBack("ctl00$cphMain$lnkNameserverUpdate", "")
  </code></pre>
  
  <p>I've tried:</p>
  
  <pre><code>webBrowser1.Document.InvokeScript("javascript:__doPostBack", new object[] { "ctl00$cphMain$lnkNameserverUpdate", "" });
  </code></pre>
  
  <p>and:</p>
  
  <pre><code>webBrowser1.Document.InvokeScript("__doPostBack", new object[] { "ctl00$cphMain$lnkNameserverUpdate", "" });
  </code></pre>
  
  <p>and a few other things. The code gets hit, but the script doesn't get fired. Any ideas would be most appreciated.</p>
  
  <p>Gregg</p>
  
  <p>BTW Here's the full element in case it's useful:</p>
  
  <pre><code>&lt;a href="javascript:__doPostBack('ctl00$cphMain$lnkNameserverUpdate','')" onmouseout="window.status=''; return true" onmouseover="window.status='Update Nameservers'; return true" id="ctl00_cphMain_lnkNameserverUpdate" onclick="javascript:Layout.ChangeIframeToSrc('DropinLoad_Domain.aspx?controlRequest=ActionNameserversWithIP');return false;"&gt;NS51.DOMAINCONTROL.COM&lt;br/&gt;NS52.DOMAINCONTROL.COM&lt;br/&gt;&lt;/a&gt;
  </code></pre>