Roman Kovalchuk
Roman Kovalchuk

Reputation: 53

How to press a button via WebBrowser - C #

There is a button-link-javascript (select the correct), I need to push it through the WebBrowser control:

function __doPostBack(eventTarget, eventArgument) {
    if (!theForm.onsubmit || (theForm.onsubmit() != false)) {
        theForm.__EVENTTARGET.value = eventTarget;
        theForm.__EVENTARGUMENT.value = eventArgument;
        theForm.submit();
    }
<a id="ctl00_plhMain_lnkSchApp" class="purplelink" href="javascript:__doPostBack('ctl00$plhMain$lnkSchApp','')">Press ME!</a>

I tried already all I know and all I could google. Through the TagName, ById, Foreach, but even nothing happens when you press it successfully. Please, tell me how to push it and get the next page (or
form ??? because the address of page does not change). Thank you.

Upvotes: 1

Views: 86

Answers (1)

Ashkan Mobayen Khiabani
Ashkan Mobayen Khiabani

Reputation: 34152

Use the InvokeMember Method.

Webbrowser.Document.GetElementById('ctl00_plhMain_lnkSchApp').InvokeMember("click");

Upvotes: 1

Related Questions