ASP内容链接组件
❮ 上一页下一章 ❯
例子
内容链接组件
建立一个目录。
内容链接组件2
使用Content Linking组件在一个文本文件中的页面之间进行导航。
ASP的内容链接组件用于创建快捷便利的导航系统!
内容链接组件返回到进行导航,用于容纳网页的列表的NEXTLINK对象。
句法
<%
Set nl=Server.CreateObject("MSWC.NextLink")
%>
首先,我们创建一个文本文件 - “links.txt”:
asp_intro.asp ASP Intro
asp_syntax.asp ASP Syntax
asp_variables.asp ASP Variables
asp_procedures.asp ASP Procedures
上面的文本文件包含页面导航。The pages must be listed in the same order you want them to be displayed, and it must also contain a description for each file name (use the tab key to separate file name from description). 该网页必须在要显示它们以相同的顺序被列出,并且它也必须包含每个文件名的描述(使用从描述以单独的文件名的标签键)。
注意:如果你想添加一个页面,或更改列表中的页面顺序;you only have to modify the text file! 你只需要修改文本文件!该导航系统会自动纠正!
然后,我们创建一个包含文件,“nlcode.inc”。The .inc file creates a NextLink object to navigate between the pages listed in "links.txt". 的。公司文件创建一个NEXTLINK对象“links.txt”中列出的页面之间进行导航。
“nlcode.inc”:
<%
dim nl
Set nl=Server.CreateObject("MSWC.NextLink")
if (nl.GetListIndex("links.txt")>1) then
Response.Write("<a href='" & nl.GetPreviousURL("links.txt"))
Response.Write("'>Previous Page</a>")
end if
Response.Write("<a href='" & nl.GetNextURL("links.txt"))
Response.Write("'>Next Page</a>")
%>
在每一个文本文件“links.txt”中列出的.asp页,放一行代码:<! - #包括文件=“nlcode.inc” - >。This line will include the code in "nlcode.inc" on every page listed in "links.txt" and the navigation will work. 这条线将包括“nlcode.inc的”代码“links.txt”中列出的每一页上和导航就可以工作。
ASP Content Linking组件的方法Method Description Example
GetListCount
Returns the number of items listed in the Content Linking List file
<%
dim nl,c
Set nl=Server.CreateObject("MSWC.NextLink")
c=nl.GetListCount("links.txt")
Response.Write("There are ")
Response.Write(c)
Response.Write(" items in the list")
%>
Output:
There are 4 items in the list
GetListIndex
Returns the index number of the current item in the Content Linking
List file. The index number of the first item is 1. 0 is returned if the
current page is not in the Content Linking List file
<%
dim nl,c
Set nl=Server.CreateObject("MSWC.NextLink")
c=nl.GetListIndex("links.txt")
Response.Write("Item number ")
Response.Write(c)
%>
Output:
Item number 3
GetNextDescription
Returns the text description of the next item listed in the Content
Linking List file. If the current page is not found in the list file it
returns the text description of the last page on the list
<%
dim nl,c
Set nl=Server.CreateObject("MSWC.NextLink")
c=nl.GetNextDescription("links.txt")
Response.Write("Next ")
Response.Write("description is: ")
Response.Write(c)
%>
Next description is: ASP Variables
GetNextURL
Returns the URL of the next item listed in the Content Linking List
file. If the current page is not found in the list file it returns the URL
of the last page on the list
<%
dim nl,c
Set nl=Server.CreateObject("MSWC.NextLink")
c=nl.GetNextURL("links.txt")
Response.Write("Next ")
Response.Write("URL is: ")
Response.Write(c)
%>
Next URL is: asp_variables.asp
GetNthDescription
Returns the description of the Nth page listed in the Content Linking
List file
<%
dim nl,c
Set nl=Server.CreateObject("MSWC.NextLink")
c=nl.GetNthDescription("links.txt",3)
Response.Write("Third ")
Response.Write("description is: ")
Response.Write(c)
%>
Third description is: ASP Variables
GetNthURL
Returns the URL of the Nth page listed in the Content Linking List file
<%
dim nl,c
Set nl=Server.CreateObject("MSWC.NextLink")
c=nl.GetNthURL("links.txt",3)
Response.Write("Third ")
Response.Write("URL is: ")
Response.Write(c)
%>
Third URL is: asp_variables.asp
GetPreviousDescription
Returns the text description of the previous item listed in the Content
Linking List file. If the current page is not found in the list file it
returns the text description of the first page on the list
<%
dim nl,c
Set nl=Server.CreateObject("MSWC.NextLink")
c=nl.GetPreviousDescription("links.txt")
Response.Write("Previous ")
Response.Write("description is: ")
Response.Write(c)
%>
Previous description is: ASP Variables