Barry
Barry

Reputation: 33

I TRIED but InvokeMember Click is NOT working on the INPUT BUTTON, it's very different from the others

I wanted button9 to automatically click an input button in the html page using webbrowser1.

This is the code of the input button below. I got this from the page source.

 <input type="image" name="phmiddle_0$ShoppingCartOrderSummary1$btnCheckout"
 id="phmiddle_0_ShoppingCartOrderSummary1_btnCheckout" title="Checkout"
 src="/content/images/global/buttons/checkout.gif" onclick="return
 GMCR.CheckoutValidation();" style="border-width:0px;">

So this is the code I used below to click it.

private void button9_Click(object sender, EventArgs e)
{
webBrowser1.Document.GetElementById("phmiddle_0$ShoppingCartOrderSummary1$btnCheckout").InvokeMember("Click");
}

And I also tried this

 private void button9_Click(object sender, EventArgs e)
{
webBrowser1.Document.GetElementById("phmiddle_0_ShoppingCartOrderSummary1_btnCheckout").InvokeMember("Click");
}

None of those two worked.

I also tried some other very long codes out there that contain var and htmlelement tags but none of them worked.

Please help me, what am I doing wrong here.

I clicked button9, but it does not automatically click the input button.

Upvotes: 1

Views: 4244

Answers (1)

Barry
Barry

Reputation: 33

I FOUND THE ANSWER ALL I HAVE TO DO IS ADD THIS webBrowser1.Document.GetElementById("phmiddle_0_ShoppingCartOrderSummary1_btnChe‌​ckout").RaiseEvent("onclick");

Upvotes: 1

Related Questions