Automatic Web Page Use With .NET
Automatic Web Page Use With .NET
Written by Ian Elliot   
Wednesday, 28 August 2013
Article Index
Automatic Web Page Use With .NET
Accessing the data
Complete Program Listing

The Complete Program

This program isn't included in the codebin because it is very specific to the website it targets and therefore can't actually be run. 

The full listing of the program as described is:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Text.RegularExpressions;

namespace NetUse
 public partial class Form1 : Form
  private int page;
  private WebBrowser webBrowser1;
  public Form1()


  private void makeBrowser()
   webBrowser1 = new System.Windows.
   webBrowser1.Name = "webBrowser1";


  private void showBrowserInForm()
   webBrowser1.Location = new    
           System.Drawing.Point(12, 300);
   webBrowser1.MinimumSize = new
           System.Drawing.Size(20, 20);
   webBrowser1.Size = new
           System.Drawing.Size(783, 338);
   webBrowser1.TabIndex = 1;

  private void button1_Click(
           object sender,
           EventArgs e)

   page = 1;
   webBrowser1.DocumentCompleted += new    
   webBrowser1.Navigate("login URL");

  private void login()
   HtmlElement name = webBrowser1.Document.
   if (name != null)
     name.InnerText = "User name";

   HtmlElement password =webBrowser1.
   if (password != null)
     password.InnerText = "password";
   HtmlElement submit = webBrowser1.
   if (submit != null)


  private void gotoData()
   webBrowser1.Navigate("URL of Data Page");

  private void getData()
   string text = webBrowser1.DocumentText;
   Regex ex1 = new
   string used = ex1.Match(text).
   textBox1.Text = used;


  void DocumentCompleted(
           object sender,    
    WebBrowserDocumentCompletedEventArgs e)
   if ( webBrowser1.ReadyState!=
     WebBrowserReadyState.Complete) return;
   switch (page)
    case 1:
     page = 2;
    case 2:
     page = 3;
    case 3:
     page = 4;



Related Articles:
Hit Highlighting with dtSearch
Automating applications using messages


blog comments powered by Disqus


To be informed about new articles on I Programmer, subscribe to the RSS feed, follow us on Google+Twitter, Linkedin or Facebook or sign up for our weekly newsletter.



Useful Windows Screensavers - Including Windows 10

The screensaver is an example of a vestigial technology - it no longer serves its original purpose. However, this doesn't mean it isn't useful in other ways and it is supported on all versions of Wind [ ... ]

Getting Started with Google Earth

Google Earth is more capable than Google Maps, but to use it you have to download a plug-in and learn a new API. This article explains that it's not so difficult and there are some easy to understand  [ ... ]

Other Projects




Last Updated ( Thursday, 16 January 2014 )

RSS feed of all content
I Programmer - full contents
Copyright © 2015 All Rights Reserved.
Joomla! is Free Software released under the GNU/GPL License.