[Lifetime of variables][Applications][The Global.asa file][ASP Built-in Objects][Response Object]
[Request Objects][Content Linking]

Content Linking

The Content Linking component creates a Nextlink object that holds a list of linked Web pages. This component generates and update tables of contents and navigational links. It is ideal for online newspapers and forum message listings. A text file, stored on the server, contains the list of the linked pages.

Syntax

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

Methods

Method

Description

GetListCount(text_file)

Counts the number of items linked in the text file

GetListIndex(text_file)

Gets the index of the current page in the text file

GetNextDescription(text_file)

Gets the description of the next page listed in the text file

GetNextURL(text_file)

Gets the URL of the next page listed in the text file

GetNthDescription(text_file, number)

Gets the description of the Nth page listed in the text file

GetNthURL(text_file, number)

Gets the URL of the Nth page listed in the text file

GetPreviousDescription(text_file)

Gets the description line of the previous page listed in the text file

GetPreviousURL(text_file)

Gets the URL of the previous pages listed in the text file

 


Content Rotator

The Content Rotator component creates a ContentRotator object that displays a different HTML content string each time a user enters or refreshes a page. A text file includes information about the content string. The content strings can contain HTML tags.

Syntax

<%
Set cr = Server.CreateObject( "MSWC.ContentRotator" )
response.write(cr.ChooseContent("sometextfile.txt")
%>

Methods

Method

Description

ChooseContent(text_file)

Gets and displays a content string

GetAllContent(text_file)

Retrieves and displays all the content strings in the text file

 


Examples

The Content Linking Component
This example builds a table of contents.

<html>
<body>
<p>
The example below builds a table of contents.
</p>
<%
dim c
dim i
set nl=server.createobject("MSWC.Nextlink")
c = nl.GetListCount("text\links.txt")
i = 1
%>
<ul>
<%do while (i <= c) %>
<li><a href="<%=nl.GetNthURL("text\links.txt", i)%>">
<%=nl.GetNthDescription("text\links.txt", i)%></a>
<%
i = (i + 1)
loop
%>
</ul>
<p>

The text file contains a list of page urls
and link descriptions. It contains one line of text for each page. Note that the url and
description MUST be
seperated by the TAB character.
</p>
<p>
<a href="text/links.txt"><img border="0" src="../images/btn_view_text.gif"></a>
</p>
</body>
</html>



The Content Linking Component 2
The example uses the Content Linking Component to navigate between the pages in a text file.

<html>
<body>

<h1>
This is page 1!
</h1>

<%
Set nl=Server.CreateObject("MSWC.NextLink")
If (nl.GetListIndex("text/links2.txt")>1) Then
%>
<a href="<%Response.Write(nl.GetPreviousURL("text/links2.txt"))%>">Previous Page</a>
<%End If%>

<a href="<%Response.Write(nl.GetNextURL("text/links2.txt"))%>">Next Page</a>

<p>The example uses the Content Linking Component
to navigate between the pages in a text file.</p>

<p>
<a href="text/links2.txt"><img border="0" src="../images/btn_view_text.gif"></a>
</p>
</body>
</html>


CharSet
This example demonstrates the Charset property. This property sets the name of the character set that is used.

<%
Response.Charset="ISO8859-1"
%>

<html>
<body>

<p>This is some text</p>

</body>
</html>

Add Extra Query Information to a Link
This example demonstrates how to send some extra query information to a page within a link, and retrieve that information on the destination page (which is, in this example, the same page).

<html>
<body>

<a href="demo_simplequerystring.asp?color=green">Example</a>

<%
Response.Write(Request.QueryString)
%>

</body>
</html>

A QueryString Collection in its Simplest Use
This example demonstrates how the QueryString collection retrieves the values from a form. The form uses the GET method, which means that the information sent is visible to everybody (in the address field). The GET method also limits the amount of information that can be sent.

<html>
<body>

<form action="demo_simplereqquery.asp" method="get">
First name: <input type="text" name="fname"><br>
Last name: <input type="text" name="lname"><br>
<input type="submit" value="Submit">
</form>

<%
Response.Write(Request.QueryString)
%>


</body>
</html>

More Information from a Form
This example demonstrates what the QueryString contains if several input fields have the same name. It shows how to separate input fields with equal names from each other. It also shows how to use the Count keyword to count the "name" property. The form uses the get method.

<html>
<body>
<%
If Request.QueryString<>"" Then
If Request.QueryString("name")<>", " Then
name1=Request.QueryString("name")(1)
name2=Request.QueryString("name")(2)
end if
end if
%>

<form action="demo_reqquery2.asp" method="get">
First name:
<input type="text" name="name" value="<%=name1%>">
<br>
Last name:
<input type="text" name="name" value="<%=name2%>">
<br>
<input type="submit" value="Submit">
</form>
<hr>
<%
If Request.QueryString<>"" Then
Response.Write("<p>")
Response.Write("The information received from the form was:")
Response.Write("</p><p>")
Response.Write("name=" & Request.QueryString("name"))
Response.Write("</p><p>")

Response.Write("The name property's count is: ")
Response.Write(Request.QueryString("name").Count)
Response.Write("</p><p>")
Response.Write("First name=" & name1)
Response.Write("</p><p>")
Response.Write("Last name=" & name2)
Response.Write("</p>")
end if
%>

</body>
</html>

Form Collection Examples

A Form Collection in its Simplest Use
This example demonstrates how the Form collection retrieves the values from a form. The form uses the POST method, which means that the information sent is invisible to others, and it has no limits (you can send a large amount of information).

<html>
<body>
<form action="demo_simpleform1.asp" method="post">
First name:
<input type="text" name="fname" value="Donald">
<br>
Last name:
<input type="text" name="lname" value="Duck">
<br>
<input type="submit" value="Submit">
</form>
<%
Response.Write(Request.Form)
%>
</body>
</html>

More Information from a Form
This example demonstrates what the Form collection contains if several input fields have the same name. It shows how to separate input fields with equal names from each other. It also shows how to use the Count keyword to count the "name" property. The form uses the post method.

<html>
<body>

<form action="demo_form2.asp" method="post">
First name:
<input type="text" name="name" value="Donald">
<br>
Last name:
<input type="text" name="name" value="Duck">
<br>
<input type="submit" value="Submit">
</form>
<hr>

<p>The information received from the form above was:</p>
<%
If Request.Form("name")<>"" Then
Response.Write("<p>")
Response.Write("name=" & Request.Form("name"))
Response.Write("</p><p>")
Response.Write("The name property's count is: ")
Response.Write(Request.Form("name").Count)
Response.Write("</p><p>")
Response.Write("First name=" & Request.Form("name")(1))
Response.Write("</p><p>")
Response.Write("Last name=" & Request.Form("name")(2))
Response.Write("</p>")
End if
%>


</body>
</html>

A Form with Checkboxes
This example demonstrates how to interact with the user through checkboxes, with the Form collection. The form uses the post method.

<html>
<body>
<%
fruits=Request.Form("fruits")
%>
<form action="demo_checkboxes.asp" method="post">
<p>Which of these fruits do you prefer:</p>
<input type="checkbox" name="fruits" value="Apples"
<%if instr(fruits,"Apple") then Response.Write("checked")%>>
Apple
<br>
<input type="checkbox" name="fruits" value="Oranges"
<%if instr(fruits,"Oranges") then Response.Write("checked")%>>
Orange
<br>
<input type="checkbox" name="fruits" value="Bananas"
<%if instr(fruits,"Banana") then Response.Write("checked")%>>
Banana
<br>
<input type="submit" value="Submit">
</form>
<%
if fruits<>"" then%>
<p>You like: <%Response.Write(fruits)%></p>
<%end if
%>

</body>
</html>

Server Variables
This example demonstrates how to find out the visitors (yours) browser type, IP address, and more with the ServerVariables collection.

<html>
<body>
<p>
<b>You are browsing this site with:</b>
<%Response.Write(Request.ServerVariables("http_user_agent"))%>
</p>
<p><b>Your IP address is:</b>
<%Response.Write(Request.ServerVariables("remote_addr"))%>
</p><p>
<b>The DNS lookup of the IP address is:</b>
<%Response.Write(Request.ServerVariables("remote_host"))%>
</p><p>
<b>The method used to call the page:</b>
<%Response.Write(Request.ServerVariables("request_method"))%>
</p>
<p>
<b>The server's domain name:</b>
<%Response.Write(Request.ServerVariables("server_name"))%>
</p>
<p>
<b>The server's port:</b>
<%Response.Write(Request.ServerVariables("server_port"))%>
</p><p>
<b>The server's software:</b>
<%Response.Write(Request.ServerVariables("server_software"))%>
</p>
</body>
</html>