473,396 Members | 1,987 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,396 software developers and data experts.

manually posting to a specific FORM

There is a site that has multiple FORM elements. How do I programatically
POST to a specific form? The individual FORM elements have a <input
name=xxx type=image return truethat is used to submit the form.

<form name="form1" action=http://abc.com METHOD="POST"><input name="submit"
type="image" onclick="return checkinput();"src="/img/submit.gif" WIDTH="56"
HEIGHT="18">Amil
Jan 30 '07 #1
8 1896
On Jan 30, 8:40 am, "Amil Hanish" <amilhan...@hotmail.comwrote:
There is a site that has multiple FORM elements. How do I programatically
POST to a specific form? The individual FORM elements have a <input
name=xxx type=image return truethat is used to submit the form.

<form name="form1" action=http://abc.comMETHOD="POST"><input name="submit"
type="image" onclick="return checkinput();"src="/img/submit.gif" WIDTH="56"
HEIGHT="18">Amil
grrhhhcfvncv

Jan 30 '07 #2
On Jan 30, 4:40 am, "Amil Hanish" <amilhan...@hotmail.comwrote:
There is a site that has multiple FORM elements. How do I programatically
POST to a specific form? The individual FORM elements have a <input
name=xxx type=image return truethat is used to submit the form.

<form name="form1" action=http://abc.comMETHOD="POST"><input name="submit"
type="image" onclick="return checkinput();"src="/img/submit.gif" WIDTH="56"
HEIGHT="18">Amil
You can use HttpWebRequest class.

Sample code on VB:

Dim web_request As HttpWebRequest = Nothing
web_request = WebRequest.Create("http://form_address")

web_request.Method = "POST"
web_request.ContentType = "application/x-www-form-urlencoded"

Dim requestData As Byte() =
Encoding.GetEncoding(1252).GetBytes("test")
web_request.ContentLength = requestData.Length

Dim response_str As String
Dim requestStream As Stream

requestStream = web_request.GetRequestStream()
requestStream.Write(requestData, 0, requestData.Length)
requestStream.Close()

Jan 30 '07 #3
You cannot "POST to a specific form". A form makes a POST, and it is either
to the same page or another page. What you can do is pass an identifier field
(hidden field, for example) that tells you "which" of your FORM Tags made the
post.
Peter

--
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
Short urls & more: http://ittyurl.net


"Amil Hanish" wrote:
There is a site that has multiple FORM elements. How do I programatically
POST to a specific form? The individual FORM elements have a <input
name=xxx type=image return truethat is used to submit the form.

<form name="form1" action=http://abc.com METHOD="POST"><input name="submit"
type="image" onclick="return checkinput();"src="/img/submit.gif" WIDTH="56"
HEIGHT="18">Amil
Jan 30 '07 #4
I don't think you understand. There is an EXISTING site (not .NET) that has
three FORM elements. I'm writing a .NET program (Windows Service) that
needs to POST to a specific FORM of the EXISTING site. I'm setting my url
to the "action" of the specific form and trying to add all the content by 1)
setting the ContentLength and 2) writing the content to the request
stream...but it doesn't seem to be working.

Amil

"Amil Hanish" <am********@hotmail.comwrote in message
news:uo**************@TK2MSFTNGP03.phx.gbl...
There is a site that has multiple FORM elements. How do I programatically
POST to a specific form? The individual FORM elements have a <input
name=xxx type=image return truethat is used to submit the form.

<form name="form1" action=http://abc.com METHOD="POST"><input
name="submit" type="image" onclick="return
checkinput();"src="/img/submit.gif" WIDTH="56" HEIGHT="18">Amil

Jan 30 '07 #5


On Jan 30, 2:33 pm, "Amil Hanish" <amilhan...@hotmail.comwrote:
I don't think you understand. There is an EXISTING site (not .NET) that has
three FORM elements. I'm writing a .NET program (Windows Service) that
needs to POST to a specific FORM of the EXISTING site. I'm setting my url
to the "action" of the specific form and trying to add all the content by 1)
setting the ContentLength and 2) writing the content to the request
stream...but it doesn't seem to be working.
Amil, give us the code of the form.

Jan 30 '07 #6
The site is the UPS site...the tracking page...so you can view full source
there. I'm just trying to automate where I insert a tracking # and agree to
the terms. Here is a very brief snippet of the form (although there are
other forms in the full source).

When I do the POST using my httpwebrequest object, all is fine, but I just
get the same page back...no errors or anything. I'm posting to the same url
as the "action" tag below. Thanks.
<html xmlns="http://www.w3.org/1999/xhtml">

<head><title></title></head>

<body>

....

<form name="trkinput" action="http://wwwapps.ups.com/WebTracking/track"
METHOD="POST">

<input type="hidden" name="loc" value="en_US" />

<input type="hidden" name="HTMLVersion" value="5.0" />

<input type="hidden" name="saveNumbers" value="null" />

<p></p>

<textarea rows="5" cols="40" name="trackNums" class="modTxtAreaTrack">

</textarea>

<p></p>

<input name="AgreeToTermsAndConditions" type="checkbox" value="yes" />

By selecting this box and the Track button, I agree to the

<a href="javascript:helpModLvl('/WebTracking/terms?loc=en_US')">

Terms and Conditions

<img alt="" src="/img/1.gif" align="bottom" border="0" height="7"
width="3"><img alt="" src="/img/icn_popup_blue.gif" align="bottom"
border="0" height="9" width="9" /></a>.

<p></p>

<input name="track" type="image" onclick="return
wrapperCheckTerms(trkinput);"

src="/img/en/btn_track_a_v2.gif" WIDTH="56" HEIGHT="18" alt="Track" />

</form>

</body>

</html>
"Alexey Smirnov" <al************@gmail.comwrote in message
news:11**********************@v33g2000cwv.googlegr oups.com...
>

On Jan 30, 2:33 pm, "Amil Hanish" <amilhan...@hotmail.comwrote:
>I don't think you understand. There is an EXISTING site (not .NET) that
has
three FORM elements. I'm writing a .NET program (Windows Service) that
needs to POST to a specific FORM of the EXISTING site. I'm setting my
url
to the "action" of the specific form and trying to add all the content by
1)
setting the ContentLength and 2) writing the content to the request
stream...but it doesn't seem to be working.

Amil, give us the code of the form.

Jan 30 '07 #7
On 30 Jan., 19:06, "Amil" <amilhan...@hotmail.comwrote:
The site is the UPS site...the tracking page...so you can view full source
Amil, did you check this page?
http://www.ups.com/content/us/en/bus...ng/technology/
automated_shipping/online_tools.html

Jan 30 '07 #8
Excellent! Works like a charm! I've only tried the HTML tracking, but very
easy. Thanks!

Amil

"Alexey Smirnov" <al************@gmail.comwrote in message
news:11**********************@s48g2000cws.googlegr oups.com...
On 30 Jan., 19:06, "Amil" <amilhan...@hotmail.comwrote:
>The site is the UPS site...the tracking page...so you can view full
source

Amil, did you check this page?
http://www.ups.com/content/us/en/bus...ng/technology/
automated_shipping/online_tools.html

Jan 31 '07 #9

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

Similar topics

2
by: Jeff Baker | last post by:
How does one post to an ASPX page using the WebClient when the form name is required?
7
by: Ali | last post by:
Our security people have been able to copy and use the FormsAuthentication cookie. Our Authetication cookie is based on an encrypted ticket and we use FormsAuthentication.SignOut() when users...
0
by: Tim | last post by:
Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Message-ID: <u$xxJS#OEHA.3300@TK2MSFTNGP09.phx.gbl> Newsgroups: microsoft.public.dotnet.languages.vb...
10
by: Jake Forson | last post by:
Hi there, I'd like to re-create a form given only its resource file. I was going to simply read the resource file and re-create the "Form" object and all its controls as found in this file...
1
PEB
by: PEB | last post by:
POSTING GUIDELINES Please follow these guidelines when posting questions Post your question in a relevant forum Do NOT PM questions to individual experts - This is not fair on them and...
3
by: linuxadmin | last post by:
hello! i want to be able to repaint a class, derived from a form, by myself. it works automatically, when i do: protected override void OnPaint(PaintEventArgs e){ base.OnPaint(e); Graphics...
4
by: jehugaleahsa | last post by:
Hello: We are working on a large number of forms. The original approach was to use the built-in data designer, type-specific DataTables and form binding. However, we are running into various...
3
by: jeremy.gehring | last post by:
Hey all, OK I'm not much of a PHP programmer; but needs must as they say. I have written AJAX file upload system that uses a PERL CGI script so that a PHP script can get the progress (nifty...
1
by: =?Utf-8?B?RGFu?= | last post by:
I am posting data to a form using the code below (from a console app). My problem is that I'm posting my data as a generic request stream, and the page is expecting the data to have come from a...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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...
0
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...
0
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,...

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.