Is it possible to trigger a button click event in code? either in C# or JavaScript.
Edit: here is the body part of html being generated, the button's id (EL2) is not stable. every time I click run (or F5), the Id will add 1.
<body><div id='final'><div><button id="EL2">OK</button></div></div></body>
You can do this as follows:
btn.HtmlElement.InvokeMethod (false, "click");
(In LINQPad 5.41 or earlier, omit the false
argument.)
The HtmlElement property also lets you access the auto-generated ID (HtmlElement.ID
). The ID
property is writable so you can explicitly assign it if you prefer it not to be auto-generated.