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 true> that 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">AmilOn Jan 30, 8:40 am, "Amil Hanish" <amilhan...@.hotmail.com> 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 true> that 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
On Jan 30, 4:40 am, "Amil Hanish" <amilhan...@.hotmail.com> 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 true> that 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()
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 fiel
d
(hidden field, for example) that tells you "which" of your FORM Tags made th
e
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 true> that 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
>
>
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" <amilhanish@.hotmail.com> wrote in message
news:uo7xiBCRHHA.1212@.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 true> that 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
>
On Jan 30, 2:33 pm, "Amil Hanish" <amilhan...@.hotmail.com> wrote:
> I don't think you understand. There is an EXISTING site (not .NET) that ha
s
> 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.
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="http://links.10026.com/?link=java script:helpModLvl('/WebTracking/terms?loc=en_US')">
Terms and Conditions
<img alt="" src="http://pics.10026.com/?src=/img/1.gif" align="bottom" border="0" height="7"
width="3"><img alt="" src="http://pics.10026.com/?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" <alexey.smirnov@.gmail.com> wrote in message
news:1170166056.186396.311380@.v33g2000cwv.googlegroups.com...
>
> On Jan 30, 2:33 pm, "Amil Hanish" <amilhan...@.hotmail.com> wrote:
> Amil, give us the code of the form.
>
On 30 Jan., 19:06, "Amil" <amilhan...@.hotmail.com> wrote:
> 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/bu...ing/technology/
automated_shipping/online_tools.html
Excellent! Works like a charm! I've only tried the HTML tracking, but very
easy. Thanks!
Amil
"Alexey Smirnov" <alexey.smirnov@.gmail.com> wrote in message
news:1170197610.194812.201480@.s48g2000cws.googlegroups.com...
> On 30 Jan., 19:06, "Amil" <amilhan...@.hotmail.com> wrote:
> Amil, did you check this page?
> http://www.ups.com/content/us/en/bu...ing/technology/
> automated_shipping/online_tools.html
>
Thursday, March 29, 2012
manually posting to a specific FORM
Labels:
asp,
elements,
form,
individual,
manually,
multiple,
net,
posting,
programaticallypost,
specific
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment