I am trying to automatically submit a form using the webbrowser control. I use the following code to send "
currentElement.InvokeMember("submit");
Now these methods work fine. But sometimes the form may have some javascript function that is called when the button is clicked at the time of submission. So, let's say if the form has a button image called "Submit", and when the user clicks on it, the javascript somefunction () function is called, and then the form is submitted.
The problem is that I use the above InvokeMember method, then it only submits the form and does not execute the associated scripts (in this case somefunction ()), and I have to manually write the code
webBrowser1.Document.InvokeScript("somefunction");
But this requires that I know before myself if there is any function. Is there a way to submit the form and it will automatically launch all the related javascript?
And I do not know the name of the button or the identifier that the user clicked to submit the form. Since in some cases it may not even have an identifier or name, for example,
<span class="btn" onclick="somefunction()"> <img style="cursor:pointer" title="Submit" alt="Submit" src="http://stackoverflow.com/imagesbutton.png?2012"> <div id="s" style=""></div> </span>
source share