views:

803

answers:

3

I have opened a website using WebBrowser. Now I would like to programmatically click input text (textbox) field. I can not use focus because this website uses JS to unlock this field only if it's clicked and I've tried also this:

Object obj = ele.DomElement;
System.Reflection.MethodInfo mi = obj.GetType().GetMethod("click");
mi.Invoke(obj, new object[0]);

But it returns mi = null. How to do this so it will work?

+1  A: 

Very similar to my answer on your other question.

Get an HtmlElement respresentative of your textbox, and call HtmlElement.InvokeMember("click") on it.

Cam Soper
I don't have InvokeMethod only InvokeMember is it this?
tomaszs
Yes, I mistyped. My bad...
Cam Soper
A: 

Use InvokeMethhod on HtmlElement or Browser.InvokeScript function.

Alex Reitbort
A: 

If you can, use:

webbrowser1.Navigate("javascript:document.forms[0].submit()")

or something similar. For me, it's been much easier and more accurate.

Eyal