<%response.write("Hello World!")%>
<html>
<body>
<%response.write("Hello World")%>
</body>
</html>
<%@ language="javascript"%>
<html>
<body>
<%Response.Write("Hello World")%>
</body>
</html>
<html>
<body>
<%
dim name
name="Donald Duck"
response.write("My name is: " & name)
%>
</body>
</html>
<html>
<body>
<%
Dim famname(5),i
famname(0) = "Jan Egil"
famname(1) = "Tove"
famname(2) = "Hege"
famname(3) = "Stale"
famname(4) = "Kai Jim"
famname(5) = "Borge"
For i = 0 to 5
response.write(famname(i) & "<br />")
Next
%>
</body>
</html>
<html>
<body>
<%
dim i
for i=1 to 6
response.write("<h" & i & ">Header " & i & "</h" & i & ">")
next
%>
</body>
</html>
<html>
<body>
<%
dim h
h=hour(now())
response.write("<p>" & now())
response.write(" (Norwegian Time) </p>")
If h<12 then
response.write("Good Morning!")
else
response.write("Good day!")
end if
%>
</body>
</html>
<%@ language="javascript" %>
<html>
<body>
<%
var d=new Date()
var h=d.getHours()
Response.Write("<p>")
Response.Write(d + " (Norwegian Time)")
Response.Write("</p>")
if (h<12)
{
Response.Write("Good Morning!")
}
else
{
Response.Write("Good day!")
}
%>
</body>
</html>
<html>
<head>
<%
sub vbproc(num1,num2)
response.write(num1*num2)
end sub
%>
</head>
<body>
<p>
You can call a procedure like this:
</p>
<p>
Result: <%call vbproc(3,4)%>
</p>
<p>
Or, like this:
</p>
<p>
Result: <%vbproc 3,4%>
</p>
</body>
</html>
<%@ language="javascript" %>
<html>
<head>
<%
function jsproc(num1,num2)
{
Response.Write(num1*num2)
}
%>
</head>
<body>
<p>
Result: <%jsproc(3,4)%>
</p>
</body>
</html>
<html>
<head>
<%
sub vbproc(num1,num2)
Response.Write(num1*num2)
end sub
%>
<script language="javascript" runat="server">
function jsproc(num1,num2)
{
Response.Write(num1*num2)
}
</script>
</head>
<body>
<p>Result: <%call vbproc(3,4)%></p>
<p>Result: <%call jsproc(3,4)%></p>
</body>
</html>
<html>
<body>
<form action="demo_reqquery.asp" method="get">
Your name: <input type="text" name="fname" size="20">
<input type="submit" value="Submit">
</form>
<%
dim fname
fname=Request.QueryString("fname")
If fname<>"" Then
Response.Write("Hello " & fname & "!<br />")
Response.Write("How are you today?")
End If
%>
</body>
</html>
<html>
<body>
<form action="demo_simpleform.asp" method="post">
Your name: <input type="text" name="fname" size="20">
<input type="submit" value="Submit">
</form>
<%
dim fname
fname=Request.Form("fname")
If fname<>"" Then
Response.Write("Hello " & fname & "!<br />")
Response.Write("How are you today?")
End If
%>
</body>
</html>
<html>
<%
dim cars
cars=Request.Form("cars")
%>
<body>
<form action="demo_radiob.asp" method="post">
<p>Please select your favorite car:</p>
<input type="radio" name="cars"
<%if cars="Volvo" then Response.Write("checked")%>
value="Volvo">Volvo</input>
<br />
<input type="radio" name="cars"
<%if cars="Saab" then Response.Write("checked")%>
value="Saab">Saab</input>
<br />
<input type="radio" name="cars"
<%if cars="BMW" then Response.Write("checked")%>
value="BMW">BMW</input>
<br /><br />
<input type="submit" value="Submit" />
</form>
<%
if cars<>"" then
Response.Write("<p>Your favorite car is: " & cars & "</p>")
end if
%>
</body>
</html>
<form method="get" action="simpleform.asp">
First Name: <input type="text" name="fname">
<br />
Last Name: <input type="text" name="lname">
<br /><br />
<input type="submit" value="Submit">
</form>
http://www.w3schools.com/simpleform.asp?fname=Bill&lname=Gates
<body>
Welcome
<%
response.write(request.querystring("fname"))
response.write(" " & request.querystring("lname"))
%>
</body>
Welcome Bill Gates
http://www.w3schools.com/simpleform.asp
<body>
Welcome
<%
response.write(request.form("fname"))
response.write(" " & request.form("lname"))
%>
</body>
Welcome Bill Gates
<%
dim numvisits
response.cookies("NumVisits").Expires=date+365
numvisits=request.cookies("NumVisits")
%>
<html>
<body>
<%
if numvisits="" then response.cookies("NumVisits")=1
%>
Welcome! This is the first time you are visiting this Web page.
<%
else
response.cookies("NumVisits")=numvisits+1
response.write("You have visited this ")
response.write("Web page " & numvisits)
if numvisits=1 then
response.write " time before!"
else
response.write " times before!"
end if
end if
%>
</body>
</html>
<%Response.Cookies("firstname")="Alex"%>
<%
Response.Cookies("fistname")="Alex"
Response.Cookies("firstname").Expires=#May 10,2002#
%>
<%
fname=Request.Cookies("firstname")
response.write("Firstname=" & fname)
%>
Firstname=Alex
<%
Response.Cookies("user")("firstname")="John"
Response.Cookies("user")("lastname")="Smith"
Response.Cookies("user")("country")="Norway"
Response.Cookies("user")("age")="25"
%>
<%
Response.Cookies("firstname")="Alex"
Response.Cookies("user")("firstname")="John"
Response.Cookies("user")("lastname")="Smith"
Response.Cookies("user")("country")="Norway"
Response.Cookies("user")("age")="25"
%>
<html>
<body>
<%
dim x,yfor each x in Request.Cookies
response.write("<p>")
if Request.Cookies(x).HasKeys then
for each y in Request.Cookies(x)
response.write(x & ":" & y & "=" & Request.Cookies(x)(y))
response.write("<br />")
next
else
Response.Write(x & "=" & Request.Cookies(x) & "<br />")
end if
response.write "</p>"
next
%>
</body>
</html>
firstname=Alex
user:firstname=John
user:lastname=Smith
user:country=Norway
user:age=25
<a href="welcome.asp?fname=John&lname=Smith">
Go to Welcome Page
</a>
<%
fname=Request.querystring("fname")
lname=Request.querystring("lname")
response.write("<p>Hello " & fname & " " & lname & "!</p>")
response.write("<p>Welcome to my Web site!</p>")
%>
<form method="post" action="welcome.asp">
First Name: <input type="text" name="fname" value="">
Last Name: <input type="text" name="lname" value="">
<input type="submit" value="Submit">
</form>
<%
fname=Request.form("fname")
lname=Request.form("lname")
response.write("<p>Hello " & fname & " " & lname & "!</p>")
response.write("<p>Welcome to my Web site!</p>")
%>
<%
Session.Timeout=5
%>
<%
Session.Abandon
%>
Welcome <%Response.Write(Session("username"))%>
<% If Session("screenres")="low" Then%>
This is the text version of the page
<%Else%>
This is the multimedia version of the page
<%End If%>
<%
If Session.Contents("age") < 18 then
Session.Contents.Remove("sale")
End If
%>
<%Session.Contents.RemoveAll()%>
<%
Session("username")="Donald Duck"
Session("age")=50dim i
For Each i in Session.Contents
Response.Write(i & "<br />")
Next
%>
username
age
<%
dim i
dim j
j=Session.Contents.Count
Response.Write("Session variables: " & j)
For i=1 to j
Response.Write(Session.Contents(i) & "<br />")
Next
%>
Session variables: 2
Donald Duck
50
<%
dim i
For Each i in Session.StaticObjects
Response.Write(i & "<br />")
Next
%>
<script language="vbscript" runat="server">
Sub Application_OnStart
application("vartime")=""
application("users")=1
End Sub
</script>
There are <%Response.Write(Application("users"))%> active connections.
<%
dim i
For Each i in Application.Contents
Response.Write(i & "<br />")
Next
%>
<%
dim i
dim j
j = Application.Contents.Count
For i = 1 to j
Response.Write(Application.Contents) & "<br />")
Next
%>
<%
dim i
For Each i in Application.StaticObjects
Response.Write(i & "<br />")
Next
%>
<%
Application.Lock
'do some application object operations
Application.Unlock
%>
<html>
<body>
<h3>Words of Wisdom:</h3>
<p><!--#include file="wisdom.inc"--></p>
<h3>The time is:</h3>
<p><!--#include file="time.inc"--></p>
</body>
</html>
"One should never increase, beyond what is necessary,
the number of entities required to explain anything."
Here is the "time.inc" file:
<%Response.Write(Time)%>
<html>
<body>
<h3>Words of Wisdom:</h3>
<p>"One should never increase, beyond what is necessary,
the number of entities required to explain anything."</p>
<h3>The time is:</h3>
<p>11:33:42 AM</p>
</body>
</html>
<!-- #include virtual="somefilename" -->
Or
<!-- #include file="somefilename" -->
<!-- #include virtual = "/html/header.inc" -->
<!-- #include file = "headers\header.inc" -->
<% fname="header.inc"%>
<!--#include file="<%-fname%>"-->
<%
For i = 1 To n
<!--#include file="count.inc"-->
Next
%>
<% For i = 1 to n %>
<!-- #include file="count.inc" -->
<% Next %>
<script language="vbscript" runat="server">
sub Application_OnStart
''''some code
end sub
sub Application_OnEnd
''''some code
end sub
sub Session_OnStart
''''some code
end sub
sub Session_OnEnd
''''some code
end sub
</script>
<object runat="server" scope="scope" id="id" (progid="prodID"|classid="classID")>
...
</object>
| Parameter | Description |
|---|---|
| scope | Sets the scope of the object
either Session or Application |
| id | Specifies a unique id for the object |
| ProgID | An id associated with a class id.
format = [Vendor.]Component[.Version] |
| ClassID | Specifies a unique id for a COM class object
Either ProgID or ClassID must be specified |
<object runat="server" scope="session" id="MyAd" progid="MSWC.AdRotator">
</object>
<object runat="server" scope="application" id = "MyConnection"
classid="Clsid::8AD3067A-B3FC-11CF-A560-00A0C9081C21">
</object>
GLOBAL.ASA:
<object runat="server" scope="session" id="MyAd" progid="MSWC.AdRotator">
</object>
You could reference the object "MyAd" from any page in the ASP application:
SOME .ASP FILE:
<%=MyAd.GetAdvertisement("/banners/adrot.txt")%>
<!--METADATA
TYPE="TypeLib"
file="filename"
uuid="typelibraryuuid"
version="versionnumber"
lcid="localeid"
-->
| Parameter | Description |
|---|---|
| file | Specifies an absolute path to a type library
Either the file or the uuid parameter is required |
| uuid | Specifies a unique identifier for the type library
Either the file or the uuid parameter is required |
| version | Optional. Used for selecting version
If the requested version isn't found the most recent version is used. |
| localeid | Optional.
The locale identifier to be used for the type library |
| Error Code | Description |
|---|---|
| ASP 0222 | Invalid type library specification. |
| ASP 0223 | Type library not found. |
| ASP 0224 | Type library cannot be loaded. |
| ASP 0225 | Type library cannot be wrapped. |
<script language="vbscript" runat="server">
sub Session_OnStart
Session("started")=now()
end sub
</script>
<script language="vbscript" runat="server">
sub Session_OnStart
Response.Redirect("newpage.asp")
end sub
</script>
<script language="vbscript" runat="server">
sub Application_OnStart
getcustomers
end sub
sub getcustomers
set conn=Server.CreateObject("ADODB.Connection")
conn.Provider="Microsoft.Jet.OLEDB.4.0"
conn.Open "c:/webdata/northwind.mdb"
set rs=conn.execute("select name from customers")
Application("customers")=rs.GetRows
rs.Close
conn.Close
end sub
</script>
<script language="vbscript" runat="server">
Sub Application_OnStart
Application("visitors")=0
End Sub
Sub Session_OnStart
Application.Lock
Application("visitors")=Application("visitors")+1
Application.UnLock
End Sub
Sub Session_OnEnd
Application.Lock
Application("visitors")=Application("visitors")-1
Application.UnLock
End Sub
</script>
<html>
<head>
</head>
<body>
<p>
There are <%response.write(Application("visitors"))%>
online now!
</p>
</body>
</html>
| Collection | Description |
|---|---|
| Cookies | Sets a cookie value.
If the cookie doesn't exist, it will be created and take the specified value |
| Property | Description |
|---|---|
| Buffer | Specifies whether to buffer the page output |
| CacheControl | Sets whether a proxy server can cache the ASP output |
| Charset | Appends the name of a character-set to the
content-type header in the Response object |
| ContentType | Sets the HTTP content type for the Response object |
| Expires | Sets how long a page will be cached on a browser |
| ExpiresAbsolute | Sets a date and time a cached page will expire |
| IsClientConnected | Indicates if the client has disconnected |
| Pics | Appends a value to the PICS label response header |
| Status | Specifies the value of the status line
returned by the server |
| Method | Description |
|---|---|
| AddHeader | Adds a new HTTP header and a value
to the HTTP response |
| AppendToLog | Adds a string to the end of the server log |
| BinaryWrite | Writes data directly to the output
without any character conversion |
| Clear | Clears any buffered HTML output |
| End | Stops processing a script
and returns the current result |
| Flush | Sends buffered HTML output immediately |
| Redirect | Redirects the user to a different URL |
| Write | Writes a specified string to the output |
<html>
<body>
<%
response.write("Hello World!")
%>
</body>
</html>
<html>
<body>
<%
response.write("<h2>
You can use HTML tags to format the text!
</h2>")
%>
<%
response.write("<p style='color:#0000ff'>
This text is styled with the style attribute!
</p>")
%>
</body>
</html>
<%
if Request.Form("select")<>"" then
Response.Redirect(Request.Form("select"))
end if
%>
<html>
<body>
<form action="demo_redirect.asp" method="post">
<input type="radio" name="select" value="demo_server.asp">
Server Example<br>
<input type="radio" name="select" value="demo_text.asp">
Text Example<br><br>
<input type="submit" value="Go!">
</form>
</body>
</html>
<html>
<body>
<%
randomize()
r=rnd()
if r>0.5 then
response.write("<a href='http://www.w3schools.com'>
W3Schools.com!
</a>")
else
response.write("<a href='http://www.refsnesdata.no'>
Refsnesdata.no!
</a>")
end if
%>
<p>
This example demonstrates a link, each time you load the page,
it will display one of two links: W3Schools.com! OR Refsnesdata.no!
There is a 50% chance for each of them.
</p>
</body>
</html>
<%
Response.Buffer=true
%>
<html>
<body>
<p>
This text will be sent to your browser when my response buffer
is flushed.
</p>
<%
Response.Flush
%>
</body>
</html>
<%
Response.Buffer=true
%>
<html>
<body>
<p>This is some text I want to send to the user.</p>
<p>No, I changed my mind. I want to clear the text.</p>
<%
Response.Clear
%>
</body>
</html>
<html>
<body>
<p>I am writing some text. This text will never be<br>
<%
Response.End
%>
finished! It's too late to write more!
</p>
</body>
</html>
<%Response.Expires=-1%>
<html>
<body>
<p>This page will be refreshed with each access!</p>
</body>
</html>
<%
Response.ExpiresAbsolute=#May 05,2001 05:30:30#
%>
<html>
<body>
<p>This page will expire on May 05, 2001 05:30:30!</p>
</body>
</html>
<html>
<body>
<%
If Response.IsClientConnected=true then
Response.Write("The user is still connected!")
else
Response.Write("The user is not connected!")
end if
%>
</body>
</html>
<%
Response.ContentType="text/html"
%>
<html>
<body>
<p>This is some text</p>
</body>
</html>
<%
Response.Charset="ISO8859-1"
%>
<html>
<body>
<p>This is some text</p>
</body>
</html>
| Collection | Description |
|---|---|
| ClientCertificate | Contains all field values in the clientcertificate |
| Cookies | Contains all cookie values sent in an HTTP request |
| Form | Contains all the form (input) values from a
form that uses the post method |
| QueryString | Contains all the variable values in an
HTTP query string |
| ServerVariables | Contains all the server variable values |
| Property | Description |
|---|---|
| TotalBytes | Returns the total number of bytes the client
sent in the body of the request |
| Method | Description |
|---|---|
| BinaryRead | Retrieves the data sent to the server from the client
as part of a post request and stores it in a safe array |
<html>
<body>
<a href="demo_simplequerystring.asp?color=green">Example</a>
<%
Response.Write(Request.QueryString)
%>
</body>
</html>
<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>
<html>
<body>
<form action="demo_reqquery.asp" method="get">
Your name: <input type="text" name="fname" size="20">
<input type="submit" value="Submit">
</form>
<%
dim fname
fname=Request.QueryString("fname")
If fname<>"" Then
Response.Write("Hello " & fname & "!<br />")
Response.Write("How are you today?")
End If
%>
</body>
</html>
<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>
<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>
<html>
<body>
<form action="demo_simpleform.asp" method="post">
Your name: <input type="text" name="fname" size="20">
<input type="submit" value="Submit">
</form>
<%
dim fname
fname=Request.Form("fname")
If fname<>"" Then
Response.Write("Hello " & fname & "!<br />")
Response.Write("How are you today?")
End If
%>
</body>
</html>
<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>
<html>
<%
dim cars
cars=Request.Form("cars")
%>
<body>
<form action="demo_radiob.asp" method="post">
<p>Please select your favorite car:</p>
<input type="radio" name="cars"
<%if cars="Volvo" then Response.Write("checked")%>
value="Volvo">Volvo</input>
<br />
<input type="radio" name="cars"
<%if cars="Saab" then Response.Write("checked")%>
value="Saab">Saab</input>
<br />
<input type="radio" name="cars"
<%if cars="BMW" then Response.Write("checked")%>
value="BMW">BMW</input>
<br /><br />
<input type="submit" value="Submit" />
</form>
<%
if cars<>"" then
Response.Write("<p>Your favorite car is: " & cars & "</p>")
end if
%>
</body>
</html>
<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>
<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>
<%
dim numvisits
response.cookies("NumVisits").Expires=date+365
numvisits=request.cookies("NumVisits")
%>
<html>
<body>
<%
if numvisits="" then
response.cookies("NumVisits")=1
%>
Welcome! This is your first time visiting this Web page.
<%
else
response.cookies("NumVisits")=numvisits+1
response.write("You have visited this ")
response.write("Web page " & numvisits)
if numvisits=1 then
response.write " time before!"
else
response.write " times before!"
end if
end if
%>
</body>
</html>
<html>
<body>
<form action="demo_totalbytes.asp" method="post">
Please type something:
<input type="text" name="txt"><br><br>
<input type="submit" value="Submit">
</form>
<%
If Request.Form("txt")<>"" Then
Response.Write("You submitted: ")
Response.Write(Request.Form)
Response.Write("<br><br>")
Response.Write("Total bytes: ")
Response.Write(Request.Totalbytes)
End If
%>
</body>
</html>
| Collection | Description |
|---|---|
| Contents | Contains all the items appended to the
application through a script command |
| StaticObjects | Contains all the objets appended to the
application with teh HTML <object> tag. |
| Method | Description |
|---|---|
| Contents.Remove | Deletes an item from the Contents collection |
| Contents.RemoveAll() | Deletes all items from the Contents collection |
| Lock | Prevents other users from modifying the variables
in the application object |
| Unlock | Enables other users to modifythe variables
in the application object after a lock |
| Event | Description |
|---|---|
| Application_OnEnd | Occurs when all user sessions are over
and the application ends |
| Application_OnStart | Occurs before the first new session is created
When the application object is first referenced |
| Collection | Description |
|---|---|
| Contents | Contains all the items appended to the session
through a script command |
| StaticObjects | Contains all the objects appended to the session
using the HTML <object> tag. |
| Property | Description |
|---|---|
| CodePage | Specifies the character set that will be used
when displaying dynamic content. |
| LCID | Sets or returns an integer that specifies a location or region.
Contents like date, time and currency will be displayed according to that location or region. |
| SessionID | Returns a unique id for each user.
The id is generated by the server. |
| Timeout | Sets or returns the timeout period in minutes
for the Session object in this application. |
| Method | Description |
|---|---|
| Abandon | Destroys a user session |
| Contens.Remove | Delets an item from the Contents collection. |
| Contents.RemoveAll() | Delets all items from the Contents collection |
| Event | Description |
|---|---|
| Session_OnEnd | Occurs when the session ends |
| Session_OnStart | Occurs when the session starts |
<html>
<body>
<%
response.write("<p>")
response.write("The default LCID for this page is: " & Session.LCID & "<br />")
response.write("The Date format for the above LCID is: " & date() & "<br />")
response.write("The Currency format for the above LCID is: " & FormatCurrency(350))
response.write("</p>")
Session.LCID=1036
response.write("<p>")
response.write("The LCID is now changed to: " & Session.LCID & "<br />")
response.write("The Date format for the above LCID is: " & date() & "<br />")
response.write("The Currency format for the above LCID is: " & FormatCurrency(350))
response.write("</p>")
Session.LCID = 3079
response.write("<p>")
response.write("The LCID is now changed to: " & Session.LCID & "<br />")
response.write("The Date format for the above LCID is: " & date() & "<br />")
response.write("The Currency format for the above LCID is: " & FormatCurrency(350))
response.write("</p>")
Session.LCID = 2057
response.write("<p>")
response.write("The LCID is now changed to: " & Session.LCID & "<br />")
response.write("The Date format for the above LCID is: " & date() & "<br />")
response.write("The Currency format for the above LCID is: " & FormatCurrency(350))
response.write("</p>")
%>
</body>
</html>
<html>
<body>
<%
Response.Write(Session.SessionID)
%>
</body>
</html>
<html>
<body>
<%
response.write("<p>")
response.write("Default Timeout is: " & Session.Timeout & " minutes.")
response.write("</p>")
Session.Timeout=30
response.write("<p>")
response.write("Timeout is now: " & Session.Timeout & " minutes.")
response.write("</p>")
%>
</body>
</html>
| Property | Description |
|---|---|
| ScriptTimeout | Sets or returns the maximum number of seconds a script
can run before it is terminated |
| Method | Description |
|---|---|
| CreateObject | Creates an instance of an object. |
| Execute | Executes an ASP file from inside an ASP file |
| GetLastError() | Returns an ASPError object that describes
the error condition that occurred |
| HTMLEncode | Applies HTML encoding to a specified string |
| MapPath | Maps a specified path to a physical path |
| Transfer | Sends,(transfers), all the information created
in one ASP file to another. |
| URLEncode | Applies URL encoding rules to a specified string |
<html>
<body>
<%
Set fs = Server.CreateObject("Scripting.FileSystemObject")
Set rs = fs.GetFile(Server.MapPath("demo_lastmodified.asp"))
modified = rs.DateLastModified
%>
This file was last modified on:
<%
response.write(modified)
Set rs = Nothing
Set fs = Nothing
%>
</body>
</html>
<html>
<body>
<%
Set FS = Server.CreateObject("Scripting.FileSystemObject")
Set RS = FS.OpenTextFile(Server.MapPath("text") & "\TextFile.txt",1)
While not rs.AtEndOfStream
Response.Write RS.ReadLine
Response.Write("<br />")
Wend
%>
<p>
<a href="text/textfile.txt">
<img border="0" src="../images/btn_view_text.gif">
</a>
</p>
</body>
</html>
<%
Set FS=Server.CreateObject("Scripting.FileSystemObject")
Set RS=FS.OpenTextFile(Server.MapPath("counter.txt"), 1, False)
fcount=RS.ReadLine
RS.Close
fcount=fcount+1
'This code is disabled due to the write access security on our server:
'Set RS=FS.OpenTextFile(Server.MapPath("counter.txt"), 2, False)
'RS.Write fcount
'RS.Close
Set RS=Nothing
Set FS=Nothing
%>
<html>
<body>
<p>
This page has been visited <%=fcount%> times.
</p>
</body>
</html>
<html>
<body>
<%
'The following line creates an error
dim i for i=1 to 1 next
'Call the GetLastError() method to trap the error
dim objerr
set objerr=Server.GetLastError()
'The variable objerr now contains the ASPError object
response.write("ASP Code=" & objerr.ASPCode)
response.write("<br />")
response.write("Number=" & objerr.Number)
response.write("<br />")
response.write("Source=" & objerr.Source)
response.write("<br />")
response.write("Filename=" & objerr.File)
response.write("<br />")
response.write("LineNumber=" & objerr.Line)
%>
</body>
</html>
| Property | Description |
|---|---|
| ASPCode | Returns an error code generated by IIS. |
| ASPDescription | Returns a detailed description of the error
If the error is ASP-related. |
| Category | Returns the source of the error
ASP?, script?, object? |
| Column | Returns the column position inside the file
that generated the error |
| Description | Returns a short description of the error |
| File | Returns the name of the ASP file
that generated the error |
| Line | Returns the line number where the
error was detected |
| Number | Returns the standard COM error code for the error |
| Source | Returns the source code of the line
where the error occurred |
| Property | Description |
|---|---|
| Drives | Returns a collection of all drive objects on the computer |
| Method | Description |
|---|---|
| BuildPath | Appends a name to an exisiting path |
| CopyFile | Copies one or more files |
| CopyFolder | Copies one or more files |
| CreateFolder | Creates a new folder |
| CreateTextFile | Creates a text file and returns a TextStream object
that can be used to read from or write to the file |
| DeleteFile | Deletes one or more files |
| DeleteFolder | Deletes one or more files |
| DriveExists | Checks if a drive exists |
| FileExists | Checks if a file exists |
| FolderExists | Checks if a folder exists |
| GetAbsolutPathName | Returns the complete path from the root |
| GetBaseName | Returns the base name of a specified file or folder |
| GetDrive | Returns a Drive object for the specified drive |
| GetDriveName | Returns the drive name of a specified path |
| GetExtensionName | Returns the file extension name for the last
component in a specified path |
| GetFolder | Returns a Folder object for a specified path |
| GetParentFolderName | Reurns the name of the parent folder of the
last component in a specified path |
| GetSpecialFolder | Returns the path to some of Window's special folders |
| GetTempName | Returns a randomly generated temporary file or folder |
| MoveFile | Moves one or more files |
| MoveFolder | Moves one or more files |
| OpenTextFile | Opens a file and returns a TExtStream object that
can be used to access the file |
<%
dim fs,fname
set fs=Server.CreateObject("Scripting.FileSystemObject")
set fname=fs.CreateTextFile("c:\test.txt",true)
fname.WriteLine("Hello World!")
fname.Close
set fname=nothing
set fs=nothing
%>
<html>
<body>
<%
Set fs=Server.CreateObject("Scripting.FileSystemObject")
If (fs.FileExists("c:\winnt\cursors\3dgarro.cur"))=true Then
Response.Write("File c:\winnt\cursors\3dgarro.cur exists.")
Else
Response.Write("File c:\winnt\cursors\3dgarro.cur does not exist.")
End If
set fs=nothing
%>
</body>
</html>
<html>
<body>
<%
Set fs=Server.CreateObject("Scripting.FileSystemObject")
If fs.FolderExists("c:\temp") = true Then
Response.Write("Folder c:\temp exists.")
Else
Response.Write("Folder c:\temp does not exist.")
End If
set fs=nothing
%>
</body>
</html>
<html>
<body>
<%
Set fs=Server.CreateObject("Scripting.FileSystemObject")
if fs.driveexists("c:") = true then
Response.Write("Drive c: exists.")
Else
Response.Write("Drive c: does not exist.")
End If
Response.write("<br>")
if fs.driveexists("g:") = true then
Response.Write("Drive g: exists.")
Else
Response.Write("Drive g: does not exist.")
End If
set fs=nothing
%>
</body>
</html>
<html>
<body>
<%
Set fs=Server.CreateObject("Scripting.FileSystemObject")
p=fs.GetDriveName("c:\winnt\cursors\3dgarro.cur")
Response.Write("The drive name is: " & p)
set fs=nothing
%>
</body>
</html>
<html>
<body>
<%
Set fs=Server.CreateObject("Scripting.FileSystemObject")
p=fs.GetParentFolderName("c:\winnt\cursors\3dgarro.cur")
Response.Write("The parent folder name of c:\winnt\cursors\3dgarro.cur is: " & p)
set fs=nothing
%>
</body>
</html>
<html>
<body>
<%
Set fs=Server.CreateObject("Scripting.FileSystemObject")
Response.Write("The file extension of the file 3dgarro is: ")
Response.Write(fs.GetExtensionName("c:\winnt\cursors\3dgarro.cur"))
set fs=nothing
%>
</body>
</html>
<html>
<body>
<%
Set fs=Server.CreateObject("Scripting.FileSystemObject")
Response.Write("The file name of the last component is: ")
Response.Write(fs.GetFileName("c:\winnt\cursors\3dgarro.cur"))
set fs=nothing
%>
</body>
</html>
<html>
<body>
<%
Set fs=Server.CreateObject("Scripting.FileSystemObject")
Response.Write(fs.GetBaseName("c:\winnt\cursors\3dgarro.cur"))
Response.Write("<br />")
Response.Write(fs.GetBaseName("c:\winnt\cursors\"))
Response.Write("<br />")
Response.Write(fs.GetBaseName("c:\winnt\"))
set fs=nothing
%>
</body>
</html>
| Property | Description |
|---|---|
| AtEndOfLine | Returns true if the file pointer is immediately before
the end of line marker in a TextStream file, false if not |
| AtEndOfStream | Returns true if the file pointer is at the end of a
TextStream file, false if not |
| Column | Returns the column number of the current character
in an input stream |
| Line | Returns the current line number in a TextStream file |
| Method | Description |
|---|---|
| Close | Closes an open TextStream file |
| Read | Reads in a specified number of characters
from a TextStream file |
| ReadAll | Reads in an entire TextStream file |
| ReadLine | Reads in one line from a TextStream file |
| Skip | Skips a specified number of characters when reading
a TextStream file |
| SkipLine | Skips the next line when reading a TextStream file |
| Write | Writes specified text to a TextStream file |
| WriteLine | Writes specified text and a new line
character to a TextStream file |
| WriteBlankLines | Writes a specified number of new line
characters to a TextStream file |
<html>
<body>
<p>This is the text in the text file:</p>
<%
Set fs=Server.CreateObject("Scripting.FileSystemObject")
Set f=fs.OpenTextFile(Server.MapPath("testread.txt"), 1)
Response.Write(f.ReadAll)
f.Close
Set f=Nothing
Set fs=Nothing
%>
</body>
</html>
<html>
<body>
<p>This is the first five characters from the text file:</p>
<%
Set fs=Server.CreateObject("Scripting.FileSystemObject")
Set f=fs.OpenTextFile(Server.MapPath("testread.txt"), 1)
Response.Write(f.Read(5))
f.Close
Set f=Nothing
Set fs=Nothing
%>
</body>
</html>
<html>
<body>
<p>This is the first line of the text file:</p>
<%
Set fs=Server.CreateObject("Scripting.FileSystemObject")
Set f=fs.OpenTextFile(Server.MapPath("testread.txt"), 1)
Response.Write(f.ReadLine)
f.Close
Set f=Nothing
Set fs=Nothing
%>
</body>
</html>
<html>
<body>
<p>This is all the lines in the text file:</p>
<%
Set fs=Server.CreateObject("Scripting.FileSystemObject")
Set f=fs.OpenTextFile(Server.MapPath("testread.txt"), 1)
do while f.AtEndOfStream = false
Response.Write(f.ReadLine)
Response.Write("<br>")
loop
f.Close
Set f=Nothing
Set fs=Nothing
%>
</body>
</html>
<html>
<body>
<p>The first four characters in the text file are skipped:</p>
<%
Set fs=Server.CreateObject("Scripting.FileSystemObject")
Set f=fs.OpenTextFile(Server.MapPath("testread.txt"), 1)
f.Skip(4)
Response.Write(f.ReadAll)
f.Close
Set f=Nothing
Set fs=Nothing
%>
</body>
</html>
<html>
<body>
<p>The first line in the text file is skipped:</p>
<%
Set fs=Server.CreateObject("Scripting.FileSystemObject")
Set f=fs.OpenTextFile(Server.MapPath("testread.txt"), 1)
f.SkipLine
Response.Write(f.ReadAll)
f.Close
Set f=Nothing
Set fs=Nothing
%>
</body>
</html>
<html>
<body>
<p>This is all the lines in the text file (with line numbers):</p>
<%
Set fs=Server.CreateObject("Scripting.FileSystemObject")
Set f=fs.OpenTextFile(Server.MapPath("testread.txt"), 1)
do while f.AtEndOfStream = false
Response.Write("Line:" & f.Line & " ")
Response.Write(f.ReadLine)
Response.Write("<br>")
loop
f.Close
Set f=Nothing
Set fs=Nothing
%>
</body>
</html>
<html>
<body>
<%
Set fs=Server.CreateObject("Scripting.FileSystemObject")
Set f=fs.OpenTextFile(Server.MapPath("testread.txt"), 1)
Response.Write(f.Read(2))
Response.Write("<p>The cursor is now standing in position " &_
f.Column & " in the text file.</p>")
f.Close
Set f=Nothing
Set fs=Nothing
%>
</body>
</html>
<%
dim fs, f
set fs=Server.CreateObject("Scripting.FileSystemObject")
set f=fs.CreateTextFile("c:\test.txt",true)
f.WriteLine("Hello World!")
f.Close
set f=nothing
set fs=nothing
%>
| Property | Description |
|---|---|
| AvailableSpace | Returns the amount of available space
on a specified drive |
| DriveLetter | Returns the drive letter identifier |
| DriveType | Returns the drive type |
| FileSystem | Returns the file system in use for a drive |
| FreeSpace | Returns the amount of free space on a drive |
| IsReady | Returns true if the drive is ready, false if not |
| Path | Returns the drive path |
| RootFolder | Returns the root folder for a drive |
| SerialNumber | Returns the serial number for a drive |
| ShareName | Returns the network share name for a drive |
| TotalSize | Returns the total size of a drive |
| VolumeName | Returns the volume name for a drive |
<%
Dim fs,d
Set fs=Server.CreateObject("Scripting.FileSystemObject")
Set d=fs.GetDrive("c:")
Response.Write("Drive " & d & ":")
Response.Write("Total size in bytes: " & d.TotalSize)
set d=nothing
set fs=nothing
%>
Drive c: Total size in bytes: 4293563392
<html>
<body>
<%
Dim fs, d, n
Set fs=Server.CreateObject("Scripting.FileSystemObject")
Set d=fs.GetDrive("c:")
n = "Drive: " & d
n = n & "<br>Available Space in bytes: " & d.AvailableSpace
Response.Write(n)
set d=nothing
set fs=nothing
%>
</body>
</html>
<html>
<body>
<%
Dim fs, d, n
Set fs=Server.CreateObject("Scripting.FileSystemObject")
Set d=fs.GetDrive("c:")
n = "Drive: " & d
n = n & "<br />Free Space in bytes: " & d.FreeSpace
Response.Write(n)
set d=nothing
set fs=nothing
%>
</body>
</html>
<html>
<body>
<%
Dim fs,d,n
Set fs=Server.CreateObject("Scripting.FileSystemObject")
Set d=fs.GetDrive("c:")
n = "Drive: " & d
n = n & "<br>Total size in bytes: " & d.TotalSize
Response.Write(n)
set d=nothing
set fs=nothing
%>
</body>
</html>
<html>
<body>
<%
dim fs, d, n
set fs=Server.CreateObject("Scripting.FileSystemObject")
set d=fs.GetDrive("c:")
Response.Write("The drive letter is: " & d.driveletter)
set d=nothing
set fs=nothing
%>
</body>
</html>
<html>
<body>
<%
dim fs, d, n
set fs=Server.CreateObject("Scripting.FileSystemObject")
set d=fs.GetDrive("c:")
Response.Write("The drive type is: " & d.DriveType)
set d=nothing
set fs=nothing
%>
</body>
</html>
<html>
<body>
<%
dim fs, d, n
set fs=Server.CreateObject("Scripting.FileSystemObject")
set d=fs.GetDrive("c:")
Response.Write("The file system is: " & d.FileSystem)
set d=nothing
set fs=nothing
%>
</body>
</html>
<html>
<body>
<%
dim fs,d,n
set fs=Server.CreateObject("Scripting.FileSystemObject")
set d=fs.GetDrive("c:")
n = "The " & d.DriveLetter
if d.IsReady=true then
n = n & " drive is ready."
else
n = n & " drive is not ready."
end if
Response.Write(n)
set d=nothing
set fs=nothing
%>
</body>
</html>
<html>
<body>
<%
dim fs,d
set fs=Server.CreateObject("Scripting.FileSystemObject")
set d=fs.GetDrive("c:")
Response.Write("The path is " & d.Path)
set d=nothing
set fs=nothing
%>
</body>
</html>
<html>
<body>
<%
dim fs,d
set fs=Server.CreateObject("Scripting.FileSystemObject")
set d=fs.GetDrive("c:")
Response.Write("The rootfolder is " & d.RootFolder)
set d=nothing
set fs=nothing
%>
</body>
</html>
<html>
<body>
<%
dim fs,d
set fs=Server.CreateObject("Scripting.FileSystemObject")
set d=fs.GetDrive("c:")
Response.Write("The serialnumber is " & d.SerialNumber)
set d=nothing
set fs=nothing
%>
</body>
</html>
| Property | Description |
|---|---|
| Attributes | Sets/Returns the attibutes of a file |
| DateCreated | Returns date and time a file was created |
| DateLastAccessed | Returns the date and time a file was last accessed |
| DateLastModified | Returns the date and time a file was last modified |
| Drive | Returns the drive of the file |
| Name | Sets/Returns the file name |
| ParentFolder | Returns the folder object for the parent of a file |
| Path | Returns the file's path |
| ShortName | Returns the 8.3 short name for a file |
| ShortPath | Returns the 8.3. short path of a file |
| Size | Returns the size in bytes of a file |
| Type | Returns the file type |
| Method | Description |
|---|---|
| Copy | Copies a file to another location |
| Delete | Deletes a file |
| Move | Moves a file to another location |
| OpenAsTextStream | Opens a file and returns a TextStream object
to be used to access the file |
<html>
<body>
<%
dim fs, f
set fs=Server.CreateObject("Scripting.FileSystemObject")
set f=fs.GetFile(Server.MapPath("testread.txt"))
Response.Write("The file testread.txt was created on: " &_
f.DateCreated)
set f=nothing
set fs=nothing
%>
</body>
</html>
<html>
<body>
<%
dim fs, f
set fs=Server.CreateObject("Scripting.FileSystemObject")
set f=fs.GetFile(Server.MapPath("testread.txt"))
Response.Write("The file testread.txt was last modified on: " &_
f.DateLastModified)
set f=nothing
set fs=nothing
%>
</body>
</html>
<html>
<body>
<%
dim fs, f
set fs=Server.CreateObject("Scripting.FileSystemObject")
set f=fs.GetFile(Server.MapPath("testread.txt"))
Response.Write("The file testread.txt was last accessed on: " &_
f.DateLastAccessed)
set f=nothing
set fs=nothing
%>
</body>
</html>
<html>
<body>
<%
dim fs,f
set fs=Server.CreateObject("Scripting.FileSystemObject")
set f=fs.GetFile(Server.MapPath("testread.txt"))
Response.Write("The attributes of the file testread.txt are: " &_
f.Attributes)
set f=nothing
set fs=nothing
%>
</body>
</html>
| Collection | Description |
|---|---|
| Files | Returns a collection of all the files in a folder |
| SubFolders | Returns a collection of all the sub folders in a folder |
| Property | Description |
|---|---|
| Attributes | Sets/Returns the attributes of a folder |
| DateCreated | Returns date/time a folder was created |
| DateLastAccessed | Returns date/time a folder was last accessed |
| DateLastModified | Returns date/time a folder was last modified |
| Drive | Returns the drive letter where the folder resides |
| IsRootFolder | Returns true if it is the root folder |
| Name | Sets/Returns the name of the folder |
| ParentFolder | Returns the parent folder |
| Path | Returns the path of a folder |
| ShortName | Returns the 8.3 short name for a folder |
| ShortPath | Returns the 8.3 short path of a folder |
| Size | Returns the size of a folder |
| Type | Returns the type of the folder |
| Method | Description |
|---|---|
| Copy | Copies a folder to another location |
| Delete | Deletes a folder |
| Move | Moves a folder to another location |
| CreateTextFile | Creates a new text file in the folder
and returns a TextStream object to access it |
<%
Dim fs,fo
Set fs=Server.CreateObject("Scripting.FileSystemObject")
Set fo=fs.GetFolder("c:\test")
Response.Write("Folder created: " & fo.DateCreated)
set fo=nothing
set fs=nothing
%>
Folder created: 10/22/2001 10:01:19 AM
| Property | Description |
|---|---|
| CompareMode | Sets/Returns the comparison mode for comparing
keys in a dictionary object |
| Count | Returns the number of key/item pairs in
a dictionary object |
| Item | Sets/Returns the value of an item
in a dictionary object |
| Key | Sets a new key value for an existing key value
in a dictionary object |
| Method | Description |
|---|---|
| Add | Adds a new key/item to a dictionary object |
| Exists | Returns boolean indicating if a key exists
in the dictionary object |
| Items | Returns an array of all the items in
a dictionary object |
| Keys | Returns an array of all the keys
in a dictionary object |
| Remove | Removes one key/item pair from
the dictionary object |
| RemoveAll | Removes all key/item pairs from
a dictionary object |
<%
Dim d
Set d=Server.CreateObject("Scripting.Dictionary")
d.Add "re","Red"
d.Add "gr","Green"
d.Add "bl","Blue"
d.Add "pi","Pink"
Response.Write("The value of key gr is: " & d.Item("gr"))
%>
The value of key gr is: Green
<html>
<body>
<%
dim d
set d=Server.CreateObject("Scripting.Dictionary")
d.Add "n", "Norway"
d.Add "i", "Italy"
if d.Exists("n")= true then
Response.Write("Key exists.")
else
Response.Write("Key does not exist.")
end if
set d=nothing
%>
</body>
</html>
<html>
<body>
<%
dim d,a,i,s
set d=Server.CreateObject("Scripting.Dictionary")
d.Add "n", "Norway"
d.Add "i", "Italy"
Response.Write("<p>The values of the items are:</p>")
a=d.Items
for i = 0 To d.Count -1
s = s & a(i) & "<br>"
next
Response.Write(s)
set d=nothing
%>
</body>
</html>
<html>
<body>
<%
dim d,a,i,s
set d=Server.CreateObject("Scripting.Dictionary")
d.Add "n", "Norway"
d.Add "i", "Italy"
Response.Write("<p>The value of the keys are:</p>")
a=d.Keys
for i = 0 To d.Count -1
s = s & a(i) & "<br>"
next
Response.Write(s)
set d=nothing
%>
</body>
</html>
<html>
<body>
<%
dim d
set d=Server.CreateObject("Scripting.Dictionary")
d.Add "n", "Norway"
d.Add "i", "Italy"
Response.Write("The value of the item n is: " & d.item("n"))
set d=nothing
%>
</body>
</html>
<html>
<body>
<%
dim d
set d=Server.CreateObject("Scripting.Dictionary")
d.Add "n", "Norway"
d.Add "i", "Italy"
d.Key("i") = "it"
Response.Write("The key i has been set to it, and the value is: " & d.Item("it"))
set d=nothing
%>
</body>
</html>
<html>
<body>
<%
dim d, a, s, i
set d=Server.CreateObject("Scripting.Dictionary")
d.Add "n", "Norway"
d.Add "i", "Italy"
Response.Write("The number of key/item pairs is: " & d.Count)
set d=nothing
%>
</body>
</html>
<%
set adrotator=server.createobject("MSWC.AdRotator")
adrotator.GetAdvertisement("textfile.txt")
%>
| Property | Description | Example |
|---|---|---|
| Border | Specifies the border size | <% set adrot=Server.CreateObject("MSWC.AdRotator") adrot.Border="2" Response.Write(adrot.GetAdvertisement("ads.txt")) %> |
| Clickable | Specifies a link | <% set adrot=Server.CreateObject("MSWC.AdRotator") adrot.Clickable=false Response.Write(adrot.GetAdvertisement("ads.txt")) %> |
| TargetFrame | Name of the frame to display the ad | <% set adrot=Server.CreateObject("MSWC.AdRotator") adrot.TargetFrame="target='_blank'" Response.Write(adrot.GetAdvertisement("ads.txt")) %> |
| Method | Description | Example |
|---|---|---|
| GetAdvertiesment | Returns the HTML that displays the ad | <% set adrot=Server.CreateObject("MSWC.AdRotator") Response.Write(adrot.GetAdvertisement("ads.txt")) %> |
<%
url=Request.QueryString("url")
If url<>"" then Response.Redirect(url)
%>
<html>
<body>
<%
set adrotator=Server.CreateObject("MSWC.AdRotator")
response.write(adrotator.GetAdvertisement("ads.txt"))
%>
</body>
</html>
REDIRECT banners.asp
WIDTH 460
HEIGHT 60
BORDER 0
*
w3schools.gif
http://www.w3schools.com/
Visit W3Schools
80
microsoft.gif
http://www.microsoft.com/
Visit Microsoft
20
<%
Set MyBrow=Server.CreateObject("MSWC.BrowserType")
%>
<html>
<body>
<%
Set MyBrow=Server.CreateObject("MSWC.BrowserType")
%>
<table border="1" width="65%">
<tr>
<td width="52%">Client OS</td>
<td width="48%"><%=MyBrow.platform%></td>
</tr>
<tr>
<td >Web Browser</td>
<td ><%=MyBrow.browser%></td>
</tr>
<tr>
<td>Browser version</td>
<td><%=MyBrow.version%></td>
</tr>
<tr>
<td>Frame support?</td>
<td><%=MyBrow.frames%></td>
</tr>
<tr>
<td>Table support?</td>
<td><%=MyBrow.tables%></td>
</tr>
<tr>
<td>Sound support?</td>
<td><%=MyBrow.backgroundsounds%></td>
</tr>
<tr>
<td>Cookies support?</td>
<td><%=MyBrow.cookies%></td>
</tr>
<tr>
<td>VBScript support?</td>
<td><%=MyBrow.vbscript%></td>
</tr>
<tr>
<td>JavaScript support?</td>
<td><%=MyBrow.javascript%></td>
</tr>
</table>
</body>
</html>
[;comments]
[HTTPUserAgentHeader]
[parent=browserDefinition]
[property1=value1]
[propertyN=valueN]
[Default Browser Capability Settings]
[defaultProperty1=defaultValue1]
[defaultPropertyN=defaultValueN]
;IE 5.0
[IE 5.0]
browser=IE
Version=5.0
majorver=#5
minorver=#0
frames=TRUE
tables=TRUE
cookies=TRUE
backgroundsounds=TRUE
vbscript=TRUE
javascript=TRUE
javaapplets=TRUE
ActiveXControls=TRUE
beta=False;DEFAULT BROWSER
[*]
browser=Default
frames=FALSE
tables=TRUE
cookies=FALSE
backgroundsounds=FALSE
vbscript=FALSE
javascript=FALSE
| Parameter | Description |
|---|---|
| comments | Optional
Any line that starts with a semicolon is ignored by the BrowserType object |
| HTTPUserAgentHeader | Optional
Specifies the HTTP User Agent header to associate with the browser-property value statements specified in propertyN. Wildcard characters are allowed. |
| browserDefinition | Optional
Specifies the HTTP User Agent header-string of a browser to use as the parent browser. The current browser's definition will inherit all of the property values declared in the parent. |
| propertyN | Optional
Specifies the browser properties listed below. ActiveXControls - Supports ActiveX� controls? Backgroundsounds - Supports background sounds? Cdf - Supports channel definition format for webcasting? Tables - Supports tables? Cookies - Supports cookies? Frames - Supports frames? Javaapplets - Supports java applets? Javascript - Supports javascript? Vbscript - Supports vbscript? Browser - Specifies the name of the browser Beta - Is the browser beta software? Platform - Specifies the platform of the browser Version - Specifies the version of the browser |
| valueN | Optional
Specifies the value of propertyN. Can be a string, an integer,(prefix with #), or boolean |
| defaultPropertyN | Optional
Specifies the name of the browser property to which to assign a default value if none of the defined HTTPUserAgentHeader values match the HTTP User Agent Header sent by the browser |
| defaultValueN | Optional
Specifies the value of defaultPropertyN. Can be a string, an integer,(prefix with #), or boolean |
<%
Set nl=Server.CreateObject("MSWC.NextLink")
%>
asp_intro.asp ASP Intro
asp_syntax.asp ASP Syntax
asp_variables.asp ASP Variables
asp_procedures.asp ASP Procedures
<!-- #include file="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>")
%>
| 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 and 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 fthe 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 |
<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 separated by the TAB character.
</p>
<p>
<a href="text/links.txt">
<img border="0" src="/images/btn_view_text.gif">
</a>
</p>
</body>
</html>
<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>
<html>
<body>
<p>
<b>Note:</b> This example won't work because ASP 3.0 is not installed
on our server.
</p>
<p>
<a href="demo_textads.asp">
<img border="0" src="/images/btn_view_text.gif">
</a>
</p>
<%
set cr=server.createobject("MSWC.ContentRotator")
response.write(cr.ChooseContent("text/textads.txt"))
%>
<p>
NOTE: Because the content strings are changed randomly in the text file,
and this page has only four content strings to choose from,
sometimes the page will display the same content strings twice
in a row.
</p>
</body>
</html>
<% Set cr=Server.CreateObject("MSWC.ContentRotator") %>
%% #1
This is a great day!!
%% #2
<h1>Smile</h1>
%% #3
<img src="smiley.gif">
%% #4
Here's a <a href="http://www.w3schools.com">link.</a>
<html>
<body>
<%
set cr=server.createobject("MSWC.ContentRotator")
response.write(cr.ChooseContent("text/textads.txt"))
%>
</body>
</html>
| Method | Description | Example |
|---|---|---|
| ChooseContent | Gets and displays a content string from the file | <%
  dim cr   Set cr=Server.CreateObject("MSWC.ContentRotator")   response.write(cr.ChooseContent("text/textads.txt")) %> |
| GetAllContent | Retrieves and displays all content strings in the file | <%
  dim cr   Set cr=Server.CreateObject("MSWC.ContentRotator")   response.write(cr.GetAllContent("text/textads.txt")) %> |
|
|
|