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.



Deep Monitor Your Site

How can you find out how your dynamic web site is working? The answer is to add some sort of monitoring and the temptation to do it yourself should be resisted at all costs. You have better things to  [ ... ]

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 [ ... ]

Other Projects




Last Updated ( Thursday, 16 January 2014 )

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