473,386 Members | 1,804 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Click a button on a web page through c#

Heyas

Writing an app that will manage my local internet connection, including
rebooting the router. The web scraping part is fine (using webrequest)
to get the current router status.
There's a specific page with a button on it for "Reboot" that I would
like my application to be able to click. According to a quick 'view
source' of that page, the button calls a JS function which essentially
calls form.submit anyway. The form method=post.

Essentially I am just not sure where to start with this. Should I be
attempting to post directly to the form action page and upload the
required post data? Or is there an easy way to just click the button?

C# in .NET 3.0 July CTP.

Cheers,
Steven

Sep 3 '06 #1
6 3789

yup, you can just post and pass in the required variables. You can get this
variables from the page source or query string.

--
________________________
Warm regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
Professional VSTO.NET - Wrox/Wiley
The O.W.C. Black Book with .NET
www.lulu.com/owc, Amazon
Blog: http://www.msmvps.com/blogs/alvin
-------------------------------------------------------
"Steven Nagy" <le*********@hotmail.comwrote in message
news:11**********************@e3g2000cwe.googlegro ups.com...
Heyas

Writing an app that will manage my local internet connection, including
rebooting the router. The web scraping part is fine (using webrequest)
to get the current router status.
There's a specific page with a button on it for "Reboot" that I would
like my application to be able to click. According to a quick 'view
source' of that page, the button calls a JS function which essentially
calls form.submit anyway. The form method=post.

Essentially I am just not sure where to start with this. Should I be
attempting to post directly to the form action page and upload the
required post data? Or is there an easy way to just click the button?

C# in .NET 3.0 July CTP.

Cheers,
Steven

Sep 3 '06 #2
Even if its a POST, not a GET?
What do you do if the target page is checking the referring page/IP
and won't work if its not from its own site?

Alvin Bruney [MVP] wrote:
yup, you can just post and pass in the required variables. You can get this
variables from the page source or query string.
Sep 4 '06 #3
There's no way to circumvent the IP checking etc. No way I know of at least.
This is always the sticking point with screen scraping and back door
approaches.

--
________________________
Warm regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
Professional VSTO.NET - Wrox/Wiley
The O.W.C. Black Book with .NET
www.lulu.com/owc, Amazon
Blog: http://www.msmvps.com/blogs/alvin
-------------------------------------------------------
"Steven Nagy" <le*********@hotmail.comwrote in message
news:11*********************@m73g2000cwd.googlegro ups.com...
Even if its a POST, not a GET?
What do you do if the target page is checking the referring page/IP
and won't work if its not from its own site?

Alvin Bruney [MVP] wrote:
>yup, you can just post and pass in the required variables. You can get
this
variables from the page source or query string.

Sep 5 '06 #4
Ok but in IE, a user can click a button and it accepts it.
There must be someway to simulate this in code. Even if it means using
Macro Express!
I'd prefer not to do it that way though.
What about the new browser control in .NET2.0 ? Can I use that for
"automated surfing"?
In otherwords, have the software take the place of a user. That way the
referring page is still the correct page, and thus passes the security
check.

Anyway, its not a huge deal for me currently because the router wasn't
checking the referrer address. So it is currently working. I was also
surprised how easy the user credential stuff was.

Thanks for helps.

Sep 5 '06 #5
You can do it very easily with SWExplorerAutomation (SWEA)
(http://webunittesting.com)
Steven Nagy wrote:
Heyas

Writing an app that will manage my local internet connection, including
rebooting the router. The web scraping part is fine (using webrequest)
to get the current router status.
There's a specific page with a button on it for "Reboot" that I would
like my application to be able to click. According to a quick 'view
source' of that page, the button calls a JS function which essentially
calls form.submit anyway. The form method=post.

Essentially I am just not sure where to start with this. Should I be
attempting to post directly to the form action page and upload the
required post data? Or is there an easy way to just click the button?

C# in .NET 3.0 July CTP.

Cheers,
Steven
Sep 5 '06 #6
Nice concept. I'll definately have a play sometime this week.

Sep 5 '06 #7

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

Similar topics

2
by: Liqun Xu | last post by:
Hallo NG, I created a Button with Click-Event dynamically: System.Web.UI.WebControls.Button bt_1 = new Button(); bt_1.Click += new EventHandler(bt_1_click); and I implemented the Funktion...
11
by: CW | last post by:
I have message entry screen that's causing me a bit of an issue. At the moment, there are 2 buttons, one is used to send message to another user (btnSend) and another is used to send messages to...
3
by: Imran Aziz | last post by:
Hello All, I have a search text and button that post data and my button handler filters the repeater control. However when the button is clicked the first time. The page_load event is being called...
0
by: Demetri | last post by:
I have created a web control that can be rendered as either a linkbutton or a button. It is a ConfirmButton control that allows a developer to force a user to confirm if they intended to click it...
2
by: Chu | last post by:
Thanks everyone for taking a moment to read this. I've got a page where I use a LinkButton and I wire up a dynamic event to the button. When the user clicks the button, the event is fired as...
21
by: Ben | last post by:
Hello I have frames set up in an asp.net application and need one frame to refresh another. Seeing as events need to be registered at the time the page is sent from the server, I was wondering...
3
by: GauravGupta | last post by:
i want to know that is it posible to call button click event before page load event on post back.... please help me....
1
by: daonho | last post by:
I tried to use javascript to trigger up the button click function when user press enter key from the textbox. This function work fine with a single button click such has login page. However, if the...
1
by: ADN | last post by:
Hi, I am currently extending the GridView control and would like to add a button to the GridView so that it will automatically render one button at the top of the grid. I have a click event for...
2
by: chrisp | last post by:
I have an ASP.NET 2 page with a button that causes a credit card transaction to be authorised. The authorisation procedure may take a few seconds and so I want to prevent the user from clicking the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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,...
0
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...

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.