Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. click a button with httpwebrequest

click a button with httpwebrequest

Scheduled Pinned Locked Moved C#
comhelp
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    brsecu
    wrote on last edited by
    #1

    I'm trying to fill in a text box then hit the submit button using httpwebrequest. Here is a sample using googles home page. I just cant seem to get it to work. Thanks for the help. string Uri = "http://www.google.com"; string requestString = "q=test&btnG=Clicked"; byte[] requestData = Encoding.UTF8.GetBytes(requestString); HttpWebRequest request = null; Stream stream = null; HttpWebResponse response = null; // set up request CookieContainer _cookies = new CookieContainer(); request = (HttpWebRequest)WebRequest.Create(Uri); request.Proxy = null; request.CookieContainer = _cookies; request.Method = "POST"; request.ContentType = "application/x-www-form-urlencoded"; request.ContentLength = requestData.Length; // make form post stream = request.GetRequestStream(); stream.Write(requestData, 0, requestData.Length); // get response response = (HttpWebResponse)request.GetResponse();

    R T 2 Replies Last reply
    0
    • B brsecu

      I'm trying to fill in a text box then hit the submit button using httpwebrequest. Here is a sample using googles home page. I just cant seem to get it to work. Thanks for the help. string Uri = "http://www.google.com"; string requestString = "q=test&btnG=Clicked"; byte[] requestData = Encoding.UTF8.GetBytes(requestString); HttpWebRequest request = null; Stream stream = null; HttpWebResponse response = null; // set up request CookieContainer _cookies = new CookieContainer(); request = (HttpWebRequest)WebRequest.Create(Uri); request.Proxy = null; request.CookieContainer = _cookies; request.Method = "POST"; request.ContentType = "application/x-www-form-urlencoded"; request.ContentLength = requestData.Length; // make form post stream = request.GetRequestStream(); stream.Write(requestData, 0, requestData.Length); // get response response = (HttpWebResponse)request.GetResponse();

      R Offline
      R Offline
      Ravi Bhavnani
      wrote on last edited by
      #2

      You may find this[^] article useful. /ravi

      This is your brain on Celcius Home | Music | Articles | Freeware ravib(at)ravib(dot)com

      1 Reply Last reply
      0
      • B brsecu

        I'm trying to fill in a text box then hit the submit button using httpwebrequest. Here is a sample using googles home page. I just cant seem to get it to work. Thanks for the help. string Uri = "http://www.google.com"; string requestString = "q=test&btnG=Clicked"; byte[] requestData = Encoding.UTF8.GetBytes(requestString); HttpWebRequest request = null; Stream stream = null; HttpWebResponse response = null; // set up request CookieContainer _cookies = new CookieContainer(); request = (HttpWebRequest)WebRequest.Create(Uri); request.Proxy = null; request.CookieContainer = _cookies; request.Method = "POST"; request.ContentType = "application/x-www-form-urlencoded"; request.ContentLength = requestData.Length; // make form post stream = request.GetRequestStream(); stream.Write(requestData, 0, requestData.Length); // get response response = (HttpWebResponse)request.GetResponse();

        T Offline
        T Offline
        techbrij
        wrote on last edited by
        #3

        See Here. It shows how you can fire button click event.

        Be Good Have Good

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups