473,791 Members | 2,933 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Programatically click a web page button

Using C# and a web browser control, is there a way to programatically click a
web page button?
Dec 15 '05 #1
3 15603
KH
No, C# runs on the server, a button click occurs on the client. Try some
javascript.

..NET DLLs can be hosted as objects (like Java applets) in IE, but I don't
think that's what you're talking about.
"Pete" wrote:
Using C# and a web browser control, is there a way to programatically click a
web page button?

Dec 15 '05 #2
Pete,
Yes, assuming you have navigated the webBrowser control to the requested
page, and then obtained an DOM reference to the page model, you can use DOM
methods to call the submit method on the submit button of a form control, for
example.

But the real question is what do you *really* want to do? If this button
submits a form, you don't even need a webbrowser control for that. You can
simply construct a POST WebRequest with the correct multipart enctype and
send it out.
Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"Pete" wrote:
Using C# and a web browser control, is there a way to programatically click a
web page button?

Dec 15 '05 #3
Thanks for the response. I will look at how to use the DOM reference as you
suggested. I did try it but didn't get too far and had wondered if there was
an easier way.

What I really want to do:

Basically, a windows form program that can aceess secure sites (that I have
valid access to) and mine some data.
I wanted to use HttpWebRequest/Response but couldn't figure out how to use
for https: sites.
Most sites want userid/password, some want userid/pword/pin.
I haven't been able to find a guide to show me how to handle logon info,
site redirection, cookies, etc (at least not that I could follow well enoguh
to get to work).
So, I thought the easiest way to accomplish would be to fill in login data
on the form using HtmlElement, and then submit the form by clicking the
button.

Filling in the form was easy, clicking the button not so easy.

If you have any good (hopefully relatively easy to follow) reference on how
to do this more efficiently, that would be great.

Thanks again,
Pete

"Peter Bromberg [C# MVP]" wrote:
Pete,
Yes, assuming you have navigated the webBrowser control to the requested
page, and then obtained an DOM reference to the page model, you can use DOM
methods to call the submit method on the submit button of a form control, for
example.

But the real question is what do you *really* want to do? If this button
submits a form, you don't even need a webbrowser control for that. You can
simply construct a POST WebRequest with the correct multipart enctype and
send it out.
Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"Pete" wrote:
Using C# and a web browser control, is there a way to programatically click a
web page button?

Dec 16 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
17257
by: Csaba2000 | last post by:
I want to be able to programatically click on the center of an <INPUT type=image ...> element (I only care about IE 5.5+). This should work regardless of whether IE has focus. Normally you would do myDomElement.click and the mouse doesn't matter, but in the case of an input image element, what happens is the submitted url has something like "?x=12&y=7" appended to it (the numbers vary per mouse position on the clicked element). If you hit...
3
459
by: asr | last post by:
I've a form with a button on it. How to raise (I mean to run the code within the click event of the button) without clicking the button? Is it possible to raise the events programatically.
2
1691
by: jw56578 | last post by:
if i have an Input type Image how am i suppose to programatically submit it through JS. code: <INPUT type="text" onkeyup="javascript:if(event.keyCode==13){btnClick.click();}"> <INPUT name="btnClick" type="Image" value="Button" onclick="javascript:alert('button was clicked');">
1
1315
by: Carl Mercier | last post by:
Hi, I have a long form that post back to itself at different places (different controls). At the very end, I have a button called "Next" that post back to itself again causing some panels to be hidden and some others to be shown to simulate a "Next Page" effect. Since I have many controls that require post back, I need SmartNavigation to be turned on. SmartNavigation should work for all controls on my page, EXCEPT for the Next button...
4
1593
by: stb | last post by:
I have an empty asp:table on a form. Rows and cells in the rows are added programatically. At the end of each row, there is a cell with a button inside it. How do I catch the button's click event? dim dr as sqlDataReader Dim tempCell As TableCell dr=........
11
1595
by: Neo Geshel | last post by:
Greetings. Hopefully someone will be able to untie this Gordian Knot I have found myself bound up in. I am trying to add a submit button dynamically to a PlaceHolder. This button will help update a particular entry in a database. The button is added as thus: Sub LoadIntro() ...additional content that is dynamically loaded as well: a preview
9
2781
by: Neo Geshel | last post by:
I have strip-mined, strip-searched, and completely exhausted the Internet (up to the 30th page on Google, with 100 results per page!!), all without finding an answer to my question AS TO WHY IT IS IMPOSSIBLE TO PROGRAMMATICALLY ADD A BUTTON TO A DYNAMICALLY CREATED PAGE. Or, to be more precise, why it is impossible to have an onClick sub respond to that button’s Click event. My main page has only one line:
0
7542
by: OceanBreeze | last post by:
I have added a LinkButton to the web page programatically from server side code using ASP 2.0 and C# in my Page_Load method. I also associate this LinkButton with a LinkButton_ClickHandler_Edit and write LinkButton_ClickHandler_Edit in my C# code. I have coded linkbutton as: LB1.Text = "Edit"; LB1.Click += new System.EventHandler(LinkButton_ClickHandler_Edit); Everything is fine as yet.
6
3364
by: AppleBag | last post by:
I'm having the worst time trying to login to myspace through code. Can someone tell me how to do this? Please try it yourself before replying, only because I have asked this a couple of times in the past in other places, and while the help was much appreciated, it seemed everyone just wanted to 'theoretically' explain how to do it, but when I tried to do it myself, I couldn't login. I want to simply pass the email address and password to...
0
10426
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10207
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10154
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9029
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7537
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5430
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4109
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3713
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2913
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.