Click to See Complete Forum and Search --> : Programmatically Populate HTML Page


snowdog11
April 19th, 2003, 11:42 AM
How do you programmatically go to a specific web page, populate an HTML textbox with text (or select a control to a specific value, etc.) and simulate clicking a button all in C#? The page can be anywhere on the internet.

It is pretty simple to nagivate to a specific page with HttpWebRequest, but how do you set the value of specific components, or at least simulate a submit button click? I'm specifically talking about pages that POST their request.

Do you have to manually create the POST request? Is it possible to programmattically click a submit button?


Thanks.

pareshgh
April 21st, 2003, 03:57 PM
if you are doing this in ASP.NET application then you can load a page. check the Page properties.

if you want the WebRequest then you can use/try following code.
which will bring the web/html page right on to your door :D :D :D

WebRequest request = WebRequest.Create("http://www.microsoft.com");
WebResponse response = request.GetResponse();

StreamReader reader = new StreamReader(response.GetResponseStream());

string str = reader.ReadLine();
while(str != null)
{
Console.WriteLine(str);
str = reader.ReadLine();
}