ASP Content Linking Component
Try it - Example
Content Linking Component
This example builds a content list.
Content Linking Component 2
This example uses the Content Linking Component 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 holds a list of the web pages to navigate to.
Syntax
<%
Set nl=Server.CreateObject("MSWC.NextLink")
%>
ASP Content Linking Example
First, we create a text file - "links.txt":
asp_intro.asp ASP Introduction
asp_syntax.asp ASP Syntax
asp_variables.asp ASP Variables
asp_procedures.asp ASP Procedures
The text file above contains the pages to navigate to. The pages should be arranged in the same order as they are to be displayed, and include a description of each filename (use a tab to separate the filename from the description).
**Note:** If you want to add pages to the list, or change the order of the pages in the list, all you need to do is modify this text file! The navigation will update automatically!
Then we create an include file, "nlcode.inc". The .inc file creates a NextLink object to navigate between the pages listed in "links.txt".
"nlcode.inc":
<%
dim nl
Set nl=Server.CreateObject("MSWC.NextLink")
if (nl.GetListIndex("links.txt")>1) then
Response.Write("Previous Page")
end if
Response.Write("Next Page")
%>
Place one line of code in each .asp page listed in the text file "links.txt":This line of code references the code in "nlcode.inc" on each page listed in "links.txt", so that the navigation works.
ASP Content Linking Component Methods
| 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")
%> 输出:
There are 4 items in the list
|
| GetListIndex | Returns the index number of the current entry in the content linking list file. The index number of the first entry is 1. Returns 0 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 entry listed in the content linking list file. If the current file is not found in the list file, returns the text description of the last page in 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)
%>
Output:
Next description is: ASP Variables
| | GetNextURL | Returns the URL of the next entry listed in the content linking list file. If the current file is not found in the list file, returns the URL of the last page in 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)
%>
Output:
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)
%>
Output:
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)
%>
Output:
Third URL is: asp_variables.asp
| | GetPreviousDescription | Returns the text description of the previous entry listed in the content linking list file. If the current file is not found in the list file, returns the text description of the first page in 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)
%>
Output:
Previous description is: ASP Variables
| | GetPreviousURL | Returns the URL of the previous entry listed in the content linking list file. If the current file is not found in the list file, returns the URL of the first page in 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)
%>
Output:
Previous URL is: asp_variables.asp
|