WebBrowser Control - simulate click

I

Ian Semmel

If I have an aspx page loaded in a web browser control, can I simulate a mouse click on a particular button control ?
 
I

Ian Semmel

It's pretty clear I am not an expert.

What I have is a web page I've got using a web request to a url and getting the web response.

What I want to do is find a particulat control and simulate a mouse click.
 
M

Marc Gravell

If you have used HttpWebRequest (or WebClient), then you will have to
do it all manually. If you are using WebBrowser, then you can do this
quite simply by using DHTML - for example, to click the "I feel lucky"
button on Google's home page:

HtmlElement el = webBrowser1.Document.All["btnI"];
if (el != null) el.InvokeMember("click");

Marc
 
W

wisccal

Hi

It depends if the button executes some Javascript in the onclick
event. That, I think, you cannot simulate. But if the button just
submits a form, you can grab the form's action attribute and create a
new HttpWebRequest with that address.

Regards
Steve
 
I

Ian Semmel

Marc said:
If you have used HttpWebRequest (or WebClient), then you will have to
do it all manually. If you are using WebBrowser, then you can do this
quite simply by using DHTML - for example, to click the "I feel lucky"
button on Google's home page:

HtmlElement el = webBrowser1.Document.All["btnI"];
if (el != null) el.InvokeMember("click");

Marc

Thanks. I changed to web browser and got it to work.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top