ASP inhoud koppel komponent


Meer voorbeelde


Bou 'n inhoudsopgawe.


Gebruik die inhoudskakelkomponent om tussen die bladsye in 'n tekslêer te navigeer.


ASP inhoud koppel komponent

Die ASP Content Linking-komponent word gebruik om 'n vinnige en maklike navigasiestelsel te skep!

Die Content Linking-komponent gee 'n Nextlink-objek terug wat gebruik word om 'n lys van webbladsye te hou wat navigeer moet word.

Sintaksis

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

Voorbeeld van ASP-inhoudkoppeling

Eerstens skep ons 'n tekslêer - "links.txt":

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

Die tekslêer hierbo bevat die bladsye wat navigeer moet word. Die bladsye moet gelys word in dieselfde volgorde as wat jy wil hê hulle moet vertoon word, en dit moet ook 'n beskrywing vir elke lêernaam bevat (gebruik die tab-sleutel om lêernaam van beskrywing te skei).

Let wel: As jy 'n bladsy wil byvoeg, of die volgorde van die bladsye in die lys wil verander; jy hoef net die tekslêer te wysig! Die navigasie sal outomaties reggestel word!

Dan skep ons 'n insluit-lêer, "nlcode.inc". Die .inc-lêer skep 'n NextLink-objek om tussen die bladsye wat in "links.txt" gelys is, te navigeer.

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

In elk van die .asp-bladsye wat in die tekslêer "links.txt" gelys word, plaas een reël kode: <!-- #include file="nlcode.inc"--> . Hierdie reël sal die kode in "nlcode.inc" insluit op elke bladsy wat in "links.txt" gelys word en die navigasie sal werk.



Metodes vir ASP-inhoudkoppelingskomponent

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