CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Apr 2003
    Posts
    2

    Question Programmatically Populate HTML Page

    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.

  2. #2
    Join Date
    Nov 2002
    Location
    Singapore
    Posts
    1,890

    Thumbs up

    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

    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();
    }
    - Software Architect

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured