How to Use ASP to Create a DHTML Table of Contents from an INI FileID: Q232065
|
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.
Note: Microsoft provides programming examples for illustration only, without
warranty either expressed or implied, including, but not limited to, the
implied warranties of merchantability and/or fitness for a particular
purpose. This article assumes that you are familiar with the programming
language being demonstrated and the tools used to create and debug
procedures. Microsoft Support professionals 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
needs. If you have limited programming experience, you may want to contact
the Microsoft fee-based consulting line at (800) 936-5200. For more
information about the support options available from Microsoft, please see
the following page on the World Wide Web:
http://www.microsoft.com/support/supportnet/refguide/The following example creates a DHTML table of contents from a .ini file, which is formatted as described in the steps below.
<script language="JavaScript">
<!--
function mouseOverLink(objLink) {
objLink.style.textDecorationUnderline = 'True';
}
function mouseOutLink(objLink) {
objLink.style.textDecorationNone = 'True';
}
function mouseClickLink(objItem)
{
if (objItem.style.display =='')
objItem.style.display = 'none';
else
objItem.style.display = '';
}
//-->
</script>
<%
With Response
.Write "<ul>" & 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) & "</ul>" & vbCrLf
.Write Chr(9) & "</li>" & vbCrLf
End If
intLinkSectionCount = intLinkSectionCount + 1
.Write Chr(9) & "<li><span onMouseOver=""mouseOverLink(this);"""
.Write " onMouseOut=""mouseOutLink(this);"""
.Write " onClick=""mouseClickLink(LinkSection" & intLinkSectionCount & ");"">"
.Write objLinkSECT & "</span>" & VbCrLf
.Write Chr(9) & Chr(9) & "<ul id=""LinkSection" & intLinkSectionCount & """"
.Write " style=""display:none"">" & 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) & "<li><a href=""" & objLinkHREF & """"
.Write " style=""text-decoration:none"""
.Write " onMouseOver=""mouseOverLink(this);"""
.Write " onMouseOut=""mouseOutLink(this);"">"
.Write objLinkTITLE & "</a></li>" & VbCrLf
End If
Loop
objLinkFILE.Close
If intLinkSectionCount Then .Write Chr(9) & "</li>" & VbCrLf
.Write "</ul>" & VbCrLf
End With
%>
[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:
<%@LANGUAGE="VBSCRIPT"%>
<html>
<body>
<table>
<tr>
<td valign="top" align="left" width="200"><!--#include virtual="/links.inc"--></td>
<td valign="top" align="left">This is a test</td>
</tr>
</table>
</body>
</html>
<!--#include virtual="/links.inc"-->
This will include the code from the "Links.inc" ASP page from the root of your Web server into the current page.
Additional query words:
Keywords :
Version : winnt:4.0
Platform : winnt
Issue type : kbhowto
Last Reviewed: June 1, 1999