Auto complete a webform?

  • Thread starter Thread starter Preben Zacho
  • Start date Start date
P

Preben Zacho

I have created a webpage with a webform (one testbox and one button). Now I
want to create a C# Windows Application that loads this webpage and auto
complete the form (in other words, fills the testbox with a given value and
invoke the button so the form is posted back to the webserver).

Is that possible? If so, please post a link or some simple code to
demostrate this behaviour.

Regards

PZ
 
It calls "screen scraping". I recomed to google for this, like
http://www.google.com/search?num=30&hl=en&lr=&q=asp.net+screen+scraping

Preben Zacho said:
I have created a webpage with a webform (one testbox and one button). Now I
want to create a C# Windows Application that loads this webpage and auto
complete the form (in other words, fills the testbox with a given value and
invoke the button so the form is posted back to the webserver).

Is that possible? If so, please post a link or some simple code to
demostrate this behaviour.

--
WBR,
Michael Nemtsev :: blog: http://spaces.msn.com/laflour

"At times one remains faithful to a cause only because its opponents do not
cease to be insipid." (c) Friedrich Nietzsche
 
Hi,

Yes, you can , if you are using WebBrowser it does provide a Document
property from where you can access the web page.
 
We are you reading the webform at all?

You know the fields you want to fill, you know what you want to put in
them.

Cut to the chase, and just use System.Net.HttpWebRequest to send the
POST command to the web server.

(Taken from an MSDN example)
HttpWebRequest myHttpWebRequest =
(HttpWebRequest)WebRequest.Create("http://www.contoso.com/");

string postData="Name="+userName;

ASCIIEncoding encoding=new ASCIIEncoding();
byte[] byte1=encoding.GetBytes(postData);

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

// Set the content length of the string being posted.
myHttpWebRequest.ContentLength=postData.Length;

Stream newStream=myHttpWebRequest.GetRequestStream();
newStream.Write(byte1,0,byte1.Length);

newStream.Close();
 
Back
Top