I am currently working on web automation using C# and a WebBrowser. There is a link that I need to 'click', however, since it triggers a Javascript function, it seems that the code needs to be executed rather than simply clicking the element (i.e. element.InvokeMember("click")). Here is the href for the element, which opens an Ajax form:
javascript:__doPostBack("ctl00$cphMain$lnkNameserverUpdate", "")
I have attempted the following:
webBrowser1.Document.InvokeScript("javascript:__doPostBack", new object[] { "ctl00$cphMain$lnkNameserverUpdate", "" });
and:
webBrowser1.Document.InvokeScript("__doPostBack", new object[] { "ctl00$cphMain$lnkNameserverUpdate", "" });
and a few other methods. The code is executed, however, the script does not get triggered. Any suggestions would be greatly appreciated.
Gregg
BTW, here is the complete element in case it is helpful:
<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;">NS51.DOMAINCONTROL.COM<br/>NS52.DOMAINCONTROL.COM<br/></a>