Click here to Skip to main content
13,900,395 members
Click here to Skip to main content
Add your own
alternative version


19 bookmarked
Posted 30 Jul 2009
Licenced CPOL

HTML Inspector

, 30 Jul 2009
Rate this:
Please Sign up or sign in to vote.
HTML Inspector is a really tiny utility that I wrote to spy on HTML pages


HTML inspector is a really tiny utility that I wrote to spy on HTML pages. It is written in C# with just a couple of lines.

It uses a web browser control for displaying web pages and a property grid control to display the attributes of the selected element. We can find everything about an HTML element by just clicking on it. If you make changes in the property grid, it will be reflected on the page.


I was involved with a project that automates web pages using scripts. Small scripts can be written in VBScript to do tasks like finding an element on a web page and then clicking on it. But then came a problem. How would we get the attributes of an element without going through the tones of code that make up a page?.

The solution, HTML Inspector.

Using the Code

How does it work?

First add a click event handler to the WebBrowser’s document object’s click event. Then in the event handler, find the active element on the page and assign it to the Selected element property of the property grid.

private void Browser_DocumentCompleted
   (object sender, WebBrowserDocumentCompletedEventArgs e)
       // add a handler for Click event
       Browser.Document.Click += new HtmlElementEventHandler(Document_Click);

  void Document_Click(object sender, HtmlElementEventArgs e)
           // Assign the selected object to property grid
           PropGrid.SelectedObject = ((HtmlDocument)sender).ActiveElement;

Browse is the web browser control and PropGrid is the property grid control.

Points of Interest

The nifty technology that works behind the scenes to make things so simple is Reflection.


The icons used in this tool are from It is a really nice collection of icons that are free to use as you like. I wish to thank the author Mark James for this wonderful collection of icons.


  • 30th July, 2009 - First version released


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Software Developer (Senior) Sutherland Global Services
India India
No Biography provided

You may also be interested in...

Comments and Discussions

GeneralMy vote of 1 Pin
Anton Semenov24-Jun-14 3:28
memberAnton Semenov24-Jun-14 3:28 
GeneralMy vote of 1 Pin
mmdavis165031-Jul-09 8:16
membermmdavis165031-Jul-09 8:16 
GeneralRe: My vote of 1 Pin
TheChindu2-Aug-09 21:18
memberTheChindu2-Aug-09 21:18 
QuestionDoes not work ... perhaps with frames? Pin
Martin081531-Jul-09 1:09
professionalMartin081531-Jul-09 1:09 
GeneralMy vote of 1 Pin
Ashley Staggs30-Jul-09 8:00
memberAshley Staggs30-Jul-09 8:00 
GeneralRe: My vote of 1 Pin
Johnny J.30-Jul-09 20:03
professionalJohnny J.30-Jul-09 20:03 
GeneralMy vote of 1 Pin
Sebastien Lebreton30-Jul-09 3:00
memberSebastien Lebreton30-Jul-09 3:00 
GeneralRe: My vote of 1 Pin
Jose Menendez Póo30-Jul-09 4:43
memberJose Menendez Póo30-Jul-09 4:43 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Cookies | Terms of Use | Mobile
Web02 | 2.8.190306.1 | Last Updated 30 Jul 2009
Article Copyright 2009 by TheChindu
Everything else Copyright © CodeProject, 1999-2019
Layout: fixed | fluid