This is the code of the website :
function checkSubmit(e) { if(e && e.keyCode == 13) { document.frmLogin.submit(); } } <div class="enterButton" onclick="document.frmLogin.submit()">Sign in</div>
This is what I tried in c# :
HtmlElementCollection elc1 = webBrowser1.Document.GetElementsByTagName("div"); foreach (HtmlElement element in elc1) { if (element.GetAttribute("InnerHtml").Equals("<DIV onclick=document.frmLogin.submit() class=enterButton>Sign in</DIV>")) { element.InvokeMember("submit()"); } }
The
foreach
is working and theif
statement is working when it gets to theInvokeMember
nothing happens.
Asked
Active
Viewed 917 times
0

Heretic Monkey
- 11,687
- 7
- 53
- 122

Nathan
- 26
- 4
-
How'd you get c# running in the browser? – Oct 04 '16 at 18:09
-
@Will OP tries to call a javascript function in WebBrowser control in c# which is possible.... – L.B Oct 04 '16 at 18:13
-
I am running VS13 windows form with webbrowser controler..... – Nathan Oct 04 '16 at 18:33
-
Note that your title refers to a "submit button", which is generally the name for HTML like ``, but your code shows a `div`, which is not a button. – Heretic Monkey Oct 04 '16 at 21:30
2 Answers
0
Sorry for the trouble I just was at the wrong element:
if (element.GetAttribute("InnerHtml").Equals("Sign in"))
{
element.InvokeMember("click");
}
now it works....

Nathan
- 26
- 4
-1
Try the Invoke member method without the brackets.
element.InvokeMember("submit");

The Rookie Coder
- 124
- 8
-
-
-
Don't you want to invoke `"click"`, since the `element` is a `div`? – Heretic Monkey Oct 04 '16 at 21:28