ASP Content Linking Component

Example

Content Linking Component
In this example, we will build a content list.
Content Linking Component 2
In this example, the Content Linking component is used to navigate between pages listed in a text file.

ASP Content Linking Component

The ASP Content Linking component is used to create a quick and convenient navigation system.

The Content Linking component returns a Nextlink object, which is used to contain a list of web pages that need to be navigated.

Syntax

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

Firstly, we will create a text file - "links.txt". This file contains information about the pages that need to be navigated. The order of the pages should be the same as their display order, and it should include a description for each file (separated by tabs between the filename and the description information).

Note:If you want to add file information to the list or change the order of pages in the list, all you need to do is modify this text file! Then the navigation system will automatically update!

"links.txt":

asp_intro.asp ASP introduction
asp_syntax.asp ASP syntax
asp_variables.asp ASP variables
asp_procedures.asp ASP program 

Please place this line of code in the pages listed above: <!-- #include file="nlcode.inc"-->. This line of code will list each page that references the following code in "links.txt", so navigation can work.

"nlcode.inc":

<%
'Use the Content Linking Component 
'to navigate between the pages listed
'in links.txt
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>")
%>

Methods of the ASP Content Linking component

GetListCount method

Returns the number of items listed in the content link 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 method

Returns the index number of the current file in the content link list file. The index number of the first entry is 1. If the current page is not in the list file, then 0 is returned.

Example

<%
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 Method

Returns the text description of the next entry listed in the content link list file. If the current file is not found in the list file, then the text description of the last page in the list.

Example

<%
dim nl,c
Set nl=Server.CreateObject("MSWC.NextLink") 
c=nl.GetNextDescription("links.txt") 
Response.Write("Next ")
Response.Write("description is: ")
Response.Write(c)
%>

Output: Next description is: ASP Variables

GetNextURL Method

Returns the URL of the next entry listed in the content link list file. If the current file is not found in the list file, then the URL of the last page in the list.

Example

<%
dim nl,c
Set nl=Server.CreateObject("MSWC.NextLink") 
c=nl.GetNextURL("links.txt") 
Response.Write("Next ")
Response.Write("URL is: ")
Response.Write(c)
%>

Output: Next URL is: asp_variables.asp

GetNthDescription Method

Returns the description information of the Nth page listed in the content link list file.

Example

<%
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)
%>

Output: Third description is: ASP Variables

GetNthURL Method

Returns the URL of the Nth page listed in the content link list file.

Example

<%
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)
%>

Output: Third URL is: asp_variables.asp

GetPreviousDescription Method

Returns the text description of the previous entry listed in the content link list file. If the current file is not found in the list file, then the text description of the first page in the list.

Example

<%
dim nl,c
Set nl=Server.CreateObject("MSWC.NextLink") 
c=nl.GetPreviousDescription("links.txt") 
Response.Write("Previous ")
Response.Write("description is: ")
Response.Write(c)
%>

Output: Previous description is: ASP Variables

GetPreviousURL Method

Returns the URL of the previous entry listed in the content link list file. If the current file is not found in the list file, then the URL of the first page in the list.

Example

<%
dim nl,c
Set nl=Server.CreateObject("MSWC.NextLink") 
c=nl.GetPreviousURL("links.txt") 
Response.Write("Previous ")
Response.Write("URL is: ")
Response.Write(c)
%>

Output: Previous URL is: asp_variables.asp