ASP Content Linking

嘗試一下- 實例
Content Linking組件
本例構建一個內容列表。
Content Linking組件2
本例使用Content Linking 組件在一個文本文件所列的頁面間進行導航。
ASP Content Linking 組件
ASP Content Linking 組件用於創建快捷便利的導航系統!
Content Linking 組件會返回一個Nextlink 對象,這個對像用於容納需要導航網頁的一個列表。
語法
Set nl=Server.CreateObject("MSWC.NextLink")
%>
ASP Content Linking 實例
首先,我們會創建一個文本文件- "links.txt":
asp_syntax.asp ASP 语法
asp_variables.asp ASP 变量
asp_procedures.asp ASP 程序
上面的文本文件包含需要導航的頁面。 頁面的排列順序應該與它們的顯示順序相同,並包含對每個文件名的描述(使用製表符來分隔文件名和描述信息)。
註釋:如果您希望向列表添加頁面,或者改變在列表中的頁面順序,那麼您需要做的僅僅是修改這個文本文件而已!導航會自動更新!
然後我們創建一個引用文件,"nlcode.inc"。 .inc 文件創建一個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頁面中放置一行代碼:<!-- #include file="nlcode.inc"--> 。這行代碼會在"links.txt" 中列出每個頁面上引用"nlcode.inc" 中的代碼,這樣導航就可以工作了。
ASP Content Linking 組件的方法
方法 | 描述 | 实例 |
---|---|---|
GetListCount | 返回内容链接列表文件中所列项目的数量。 | <% 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") %> 输出: There are 4 items in the list |
GetListIndex | 返回在内容链接列表文件中当前条目的索引号。第一个条目的索引号是 1。如果当前页面不在内容链接列表文件中,则返回 0。 | <% dim nl,c Set nl=Server.CreateObject("MSWC.NextLink") c=nl.GetListIndex("links.txt") Response.Write("Item number ") Response.Write(c) %> 输出: Item number 3 |
GetNextDescription | 返回在内容链接列表文件中所列的下一个条目的文本描述。如果在列表文件中没有找到当前文件,则返回列表中最后一个页面的文本描述。 | <% 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 | 返回在内容链接列表文件中所列的下一个条目的 URL。如果在列表文件中没有找到当前文件,则返回列表中最后一个页面的 URL。 | <% 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 | 返在内容链接列表文件中所列的第 N 个页面的描述信息。 | <% 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 | 返回在内容链接列表文件中所列的第 N 个页面的 URL。 | <% 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 | 返回在内容链接列表文件中所列的前一个条目的文本描述。如果在列表文件中没有找到当前文件,则返回列表中第一个页面的文本描述。 | <% 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 |
GetPreviousURL | 返回在内容链接列表文件中所列的前一个条目的 URL。如果在列表文件中没有找到当前文件,则返回列表中第一个页面的 URL。 | <% dim nl,c Set nl=Server.CreateObject("MSWC.NextLink") c=nl.GetPreviousURL("links.txt") Response.Write("Previous ") Response.Write("URL is: ") Response.Write(c) %> 输出: Previous URL is: asp_variables.asp |