Programmatically posting form data to a web page and getting result in .net

Discussion in 'ASP .Net' started by Ghafran Abbas, Oct 12, 2004.

  1. To programmatically post form data to a web page and get the result in
    ..net, use the following code.

    ===========Begin Code================

    Imports System.Net

    Public Sub PostDataToForm()

    'URL to post the data to
    Dim strPostText As String = "http://www.google.com"

    Dim myWebClient As New WebClient
    Dim mypostvalues As New NameValueCollection

    'Add Post Fields Here
    'The first parameter is the name of the field, the second is the
    value
    mypostvalues.Add("hl", "en")
    mypostvalues.Add("q", "test search")

    Try
    Dim responseData As Byte() = myWebClient.UploadValues(strPostText,
    mypostvalues)
    sResponse = Encoding.ASCII.GetString(responseData)
    Catch
    'Handle Error Here
    Finally
    myWebClient.Dispose()
    End Try

    End Function

    ===========End Code================
    Ghafran Abbas, Oct 12, 2004
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Newbie
    Replies:
    4
    Views:
    2,520
    Bin Song
    Nov 26, 2003
  2. Stanley Beamish

    Posting to web app and reading result

    Stanley Beamish, Aug 21, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    368
    Mark Rae
    Aug 21, 2005
  3. Newbie

    Posting ASP .Net web form to another asp page

    Newbie, Nov 17, 2003, in forum: ASP .Net Web Services
    Replies:
    3
    Views:
    135
    Bin Song
    Nov 26, 2003
  4. Stanley Beamish

    Posting to web app and reading result

    Stanley Beamish, Aug 22, 2005, in forum: ASP General
    Replies:
    0
    Views:
    106
    Stanley Beamish
    Aug 22, 2005
  5. Michael Tan
    Replies:
    32
    Views:
    972
    Ara.T.Howard
    Jul 21, 2005
Loading...

Share This Page