ASP.NET, Coding

ASP Content Linking

The ASP content linking component is used to enhance the navigation capability of the site. A text file containing all the pages to be navigated is created first. The pages to be displayed are listed in that text file in the same order as you want it to be displayed along with a description for each pages. Then that file is link with the component. If a particular page is to be changed or added or deleted, only the list-file is changed. The cotent linking component creates a ‘NextLink’ object that manages a list of URLs stated in the text file. You can set the pages in your website like pages in a book. Using the same component you can generate and update tables of contents and navigational links to previous and next pages in your site. This is much used in online newspapers and forum message listings.

Syntax for creating a Content Linking Component:

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

The ASP Content Linking Component’s methods are described below:

Method     Description
GetListCount    Returns the number of items listed in the Content Linking List file
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
GetNextDescription    Returns the text description of the next item listed in the Content Linking List file. If the current pagei s  not found in the list file it returns the text description of the last page on the list
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
GetNthDescription    Returns the description of the Nth page listed in the Content Linking List file
GetNthURL    Returns the URL of the Nth page listed in the Content Linking List file
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
GetPreviousURL    Returns the URL of the previous item listed in the Content Linking List file. If the current page is n found in the list file it returns the URL of the first page on the list

Following script builds a Table of Contents:

 
    <% dim nl = Server.CreateObject("MSWC.NextLink") ctr = nl.GetListCount("links.txt") i = 1 %>

The following script adds the next page and previous page buttons to an HTML file:

<%
  set nl = Server.CreateObject("MSWC.NextLink")
  if(nl.GetListIndex("links.txt") > 1)
  then
  %>
    "> Previous Page 
  <% end if %>
   ">
  Next Page 

The links.txt file might look like:

page1.asp ASP Intro
page2.asp ASP Syntax
page3.asp ASP Variables
page3.asp ASP Procedures