Microsoft KB Archive/232065

= How to Use ASP to Create a DHTML Table of Contents from an INI File =

Article ID: 232065

Article Last Modified on 12/3/2007

-

APPLIES TO


 * Microsoft Internet Information Server 4.0
 * Microsoft Internet Information Services 5.0
 * Microsoft Internet Information Services 6.0

-



This article was previously published under Q232065



We strongly recommend that all users upgrade to Microsoft Internet Information Services (IIS) version 6.0 running on Microsoft Windows Server 2003. IIS 6.0 significantly increases Web infrastructure security. For more information about IIS security-related topics, visit the following Microsoft Web site:

http://www.microsoft.com/technet/security/prodtech/IIS.mspx



SUMMARY
Microsoft IIS and Active Server Pages (ASP) can be used to create Dynamic HTML (DHTML) pages for use with Microsoft Internet Explorer version 4.0 and later. This article explains how to create a dynamic table of contents from a .ini file with a list of URLs.



MORE INFORMATION
Note: Microsoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific requirements. The following example creates a DHTML table of contents from a .ini file, which is formatted as described in the steps below.   Save the following ASP code as "Links.inc" in the root of your Web server: 

<%  With Response .Write "" & VbCrLf Dim objLinkFSO, objLinkFILE, objLinkTEMP Dim objLinkSECT, objLinkTITLE, objLinkHREF Dim intLinkSectionCount Set objLinkFSO = Server.CreateObject("Scripting.FileSystemObject") Set objLinkFILE = objLinkFSO.OpenTextFile(Server.MapPath("./") & "\links.ini", 1, FALSE, 0) intLinkSectionCount = 0 Do While Not objLinkFILE.AtEndOfStream objLinkTEMP = Trim(objLinkFILE.ReadLine) If Left(objLinkTEMP,1) = "[" Then objLinkSECT = Trim(Mid(objLinkTEMP,2,Len(objLinkTEMP) - 2)) If intLinkSectionCount Then .Write Chr(9) & Chr(9) & "" & vbCrLf .Write Chr(9) & "" & vbCrLf End If           intLinkSectionCount = intLinkSectionCount + 1 .Write Chr(9) & "" .Write objLinkSECT & " " & VbCrLf .Write Chr(9) & Chr(9) & "" & VbCrLf ElseIf InStr(objLinkTEMP,"=") Then objLinkTITLE = Trim(Left(objLinkTEMP,Instr(objLinkTEMP,"=")-1)) objLinkHREF = Trim(Right(objLinkTEMP,Len(objLinkTEMP) - Instr(objLinkTEMP,"="))) .Write Chr(9) & Chr(9) & "" .Write objLinkTITLE & "</li>" & VbCrLf End If     Loop objLinkFILE.Close If intLinkSectionCount Then .Write Chr(9) & "</li>" & VbCrLf .Write "</ul>" & VbCrLf End With %>                       </li> Create a directory or virtual directory in the root of your Web server named "Linktest" with at least Script Access enabled.</li>  Save the following text as "Links.ini" in the "Linktest" folder:

[Section 1] Home Page=/ Microsoft Corp=http://www.microsoft.com/

[Section 2] Microsoft Network=http://www.msn.com/ IIS Documentation=/iishelp/

[Section 3] Microsoft Investor=http://investor.msn.com/ HotMail=http://www.hotmail.com/ The format for the entries is as follows:

 Section headings are in brackets as [Section Name].

</li> URLs are listed as Title=HREF, and can be absolute or relative references.</li></ul> </li>  Save the following ASP code as "Default.asp" in the "Linktest" folder: <%@LANGUAGE="VBSCRIPT"%> </li></ol>

When the example page is browsed, it will read the contents of the "Links.ini" file in the same directory and create the DHTML table of contents. Because the ASP code in the "Links.inc" file always searches the local folder for the "Links.ini" file, you can create a separate list of contents for each folder on your Web server.

To use the this code in any folder on your server, do the following: <ol>  Include the following line of code in an ASP page where you want the table of contents to be written: This will include the code from the "Links.inc" ASP page from the root of your Web server into the current page. </li> Create a file named "Links.ini" in the same folder as the page from the previous step.</li></ol>

Additional query words: iis 5 iis5 iis 6 iis 6.0 iis6

Keywords: kbhowto KB232065

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.