ASP 콘텐츠 연결 구성 요소


더 많은 예


목차를 작성합니다.


콘텐츠 연결 구성 요소를 사용하여 텍스트 파일의 페이지 사이를 탐색합니다.


ASP 콘텐츠 연결 구성 요소

ASP Content Linking 구성 요소는 빠르고 쉬운 탐색 시스템을 만드는 데 사용됩니다!

Content Linking 구성 요소는 탐색할 웹 페이지 목록을 보유하는 데 사용되는 Nextlink 개체를 반환합니다.

통사론

<%
Set nl=Server.CreateObject("MSWC.NextLink")
%>

ASP 콘텐츠 연결 예

먼저 "links.txt"라는 텍스트 파일을 만듭니다.

asp_intro.asp ASP Intro
asp_syntax.asp ASP Syntax
asp_variables.asp ASP Variables
asp_procedures.asp ASP Procedures

위의 텍스트 파일에는 탐색할 페이지가 포함되어 있습니다. 페이지는 표시하려는 순서와 동일한 순서로 나열되어야 하며 각 파일 이름에 대한 설명도 포함해야 합니다(탭 키를 사용하여 설명과 파일 이름을 구분).

참고: 페이지를 추가하거나 목록의 페이지 순서를 변경하려는 경우; 텍스트 파일만 수정하면 됩니다! 내비게이션이 자동으로 수정됩니다!

그런 다음 "nlcode.inc"라는 포함 파일을 만듭니다. .inc 파일은 "links.txt"에 나열된 페이지 사이를 탐색하기 위해 NextLink 개체를 만듭니다.

"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 콘텐츠 연결 구성 요소의 메서드

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

GetPreviousURL Returns the URL 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 URL of the first page on the list <%
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