Re: set field in web page
From: Ken Cox [Microsoft MVP] (BANSPAMken_cox_at_sympatico.ca)
Date: 06/30/04
- Next message: Lubos: "Create TemplateColumn Dynamically"
- Previous message: Jacques Leclerc: "Re: Avoiding Post Backs w/dropdowns using data islands and javascript"
- In reply to: garyfehr: "Re: set field in web page"
- Messages sorted by: [ date ] [ thread ]
Date: Tue, 29 Jun 2004 23:12:58 -0400
Hi Gary,
This is in VB.NET but it should give you the idea.
Find out what the target page wants to see as far as field names and the
submit button. Put those values into the NameValueCollection. Upload that
using UploadValues and read the result.
You can call this routine on the click event of your own page. Just change
the URL and the form field names/values.
Sub DoPost()
Dim uriString As String = _
"http://p4320/p4320work/login.aspx"
' Create a new WebClient instance.
Dim myWebClient As New System.Net.WebClient
Dim myNameValueCollection As New _
System.Collections.Specialized.NameValueCollection
myNameValueCollection.Add("txtName", "Ken")
myNameValueCollection.Add("txtPwd", "password")
myNameValueCollection.Add("Button1", "")
Dim responseArray As Byte() = myWebClient.UploadValues _
(uriString, "POST", myNameValueCollection)
Label1.Text = "Response received was :" & _
System.Text.Encoding.ASCII.GetString(responseArray)
End Sub
Ken
Microsoft MVP [ASP.NET]
"garyfehr" <garyfehr@discussions.microsoft.com> wrote in message
news:3F8667C4-F0B0-4740-BA4D-8F0394CD234A@microsoft.com...
>I think I wasn't specific enough or else I didn't understand your reply.
>What I want to do is visit a web page of a vendor and log in
>programmatically - the same as if I were sitting at a browser and typing in
>a username/password. So the first step would be to retrieve the login page
>of the vendor (which you've explained), then populate the appropriate
>fields on the page with username/password, then post this and retrieve the
>resulting response containing the page appearing after login.
>
- Next message: Lubos: "Create TemplateColumn Dynamically"
- Previous message: Jacques Leclerc: "Re: Avoiding Post Backs w/dropdowns using data islands and javascript"
- In reply to: garyfehr: "Re: set field in web page"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|