Using the Summary Info Component
By Paul HarrapIt is a relatively easy and well-documented procedure to dynamically display an HTML document's last modification date in the browser. A few simple lines of Javascript cut and pasted into the BODY of your document and javascript-enabled browsers extract and display the modification date and time.
|
This has advantages:
- It produces the correct value!
- It's dynamic!
- It's client-side, so no load on the server
- The client determines the format that
document.lastmodifiedis displayed, so this should be appropriate to the user's taste.
It also has disadvantages:
- It's client side, so some browsers might not cope.
- The client determines the format that
document.lastmodifiedis displayed, which control freak web site designers don't like!
As an ASP developer it should be a relatively easy matter to determine server side what the last modification date is, and then display and format it as I choose, entirely independently of the browser. This article shows how this can be done using the Summary Information Component, which comes as part of the IIS Resource Kit from Microsoft. You can even download the dll and example source from 4Guys!
The Summary Information Component is an astoundingly useful little piece of ActiveX. Once installed on your server you can create the object in ASP, and using it's methods and properties access the summary information of the files it is pointed at. The line below collects summary information about all the Microsoft Word (doc) files in the same directory as the ASP file.
|
The SumInfoObject is a collection of documents and their properties can be accessed and displayed on screen.
Some of the more interesting properties available are :
- Title
- Author
- Subject
- Application
- Keywords
- Comments
- LastSaveTime
- WordCount
- Bytes
These properties can either be accessed separately as the code iterates through the collection or outputted in one of the component's predetermined formats.
|
Of particular interest in the dynamic Last Modified notification is the LastSaveTime property. In order to access this property for our page, we must first ensure that the Summary Information component is targeted at the correct page. How do we do that? We must ensure that the FileSpec refers to this page and no others, and as any one file name is unique in a folder we must ascertain the name of this file. We can then create a collection with just one document contained in it - this document.
STEP ONE:
Persuade IIS to tell you the name of this file.
Perhaps not as easy as it sounds.
Accessing the Server Variables collection and specifically Script_Name gives us the file name including the full virtual root. We don't need to know which folder the file is in, just it's name, hence some string manipulation is required. We identify the position of the rightmost "/" and take only what is to it's right... which should be the file name we require.
|
STEP TWO:
Now we have our file name we can create the Summary Information Component Object and be sure that the only file in the collection is the one we are interested in.
|
STEP THREE:
This SumInfoObject is a collection with only one entry, but be careful. You cannot access the LastSaveTime properties from the collection. You must iterate through every document in the collection, even though we all know there is only one document.
|
STEP FOUR:
The lastmod is a string of the type LongDate, Time and varies according to the web server's date and time settings. From here you can isolate the comma using the INSTR command, separate the Date and Time and format them as you choose. So, you could easily print out the last modified date with a simple:
|
Well, that's it! Pretty nifty and easy, eh? Be sure to check out the Attachments for this article. Included is the Summary Information Component Object and some example ASP pages to show you how to use it!
Happy Programming!
Attachments:



