当前位置:K88软件开发文章中心编程语言AspAsp02 → 文章内容

ASP Content Linking

减小字体 增大字体 作者:佚名  来源:网上搜集  发布时间:2019-1-11 13:42:38

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_intro.asp ASP 简介asp_syntax.asp ASP 语法asp_variables.asp ASP 变量asp_procedures.asp ASP 程序上面的文本文件包含需要导航的页面。页面的排列顺序应该与它们的显示顺序相同,并包含对每个文件名的描述(使用制表符来分隔文件名和描述信息)。注释:如果您希望向列表添加页面,或者改变在列表中的页面顺序,那么您需要做的仅仅是修改这个文本文件而已!导航会自动更新!然后我们创建一个引用文件,"nlcode.inc"。.inc 文件创建一个 NextLink 对象来在 "links.txt" 中列出的页面间进行导航。"nlcode.inc":





<%dim nlSet nl=Server.CreateObject("MSWC.NextLink")if (nl.GetListIndex("links.txt")>1) thenResponse.Write("<a href='" & nl.GetPreviousURL("links.txt"))Response.Write("'>Previous Page</a>")end ifResponse.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,cSet 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 listGetListIndex返回在内容链接列表文件中当前条目的索引号。第一个条目的索引号是 1。如果当前页面不在内容链接列表文件中,则返回 0。 <%dim nl,cSet nl=Server.CreateObject("MSWC.NextLink") c=nl.GetListIndex("links.txt") Response.Write("Item number ")Response.Write(c)%>输出:Item number 3GetNextDescription返回在内容链接列表文件中所列的下一个条目的文本描述。如果在列表文件中没有找到当前文件,则返回列表中最后一个页面的文本描述。 <%dim nl,cSet nl=Server.CreateObject("MSWC.NextLink") c=nl.GetNextDescription("links.txt") Response.Write("Next ")Response.Write("description is:





")Response.Write(c)%>输出:Next description is:





ASP VariablesGetNextURL返回在内容链接列表文件中所列的下一个条目的 URL。如果在列表文件中没有找到当前文件,则返回列表中最后一个页面的 URL。<%dim nl,cSet 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.aspGetNthDescription返在内容链接列表文件中所列的第 N 个页面的描述信息。 <%dim nl,cSet 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 VariablesGetNthURL返回在内容链接列表文件中所列的第 N 个页面的 URL。<%dim nl,cSet 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.aspGetPreviousDescription返回在内容链接列表文件中所列的前一个条目的文本描述。如果在列表文件中没有找到当前文件,则返回列表中第一个页面的文本描述。 <%dim nl,cSet nl=Server.CreateObject("MSWC.NextLink") c=nl.GetPreviousDescription("links.txt") Response.Write("Previous ")Response.Write("description is:





")Response.Write(c)%>输出:Previous description is:





ASP VariablesGetPreviousURL返回在内容链接列表文件中所列的前一个条目的 URL。如果在列表文件中没有找到当前文件,则返回列表中第一个页面的 URL。 <%dim nl,cSet 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

ASP Content Linking