Examples
Write text with ASP
This example demonstrates how to write text with ASP.
Format text with HTML tags in ASP
This example demonstrates how to combine text and HTML tags with ASP.
Show a random link
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.
Controlling the buffer
This example demonstrates how you can control the buffer.
Clear the buffer
This example demonstrates how you can clear the buffer.
Set the type of content
This example demonstrates how to specify the type of content.
Set the name of the character set
This example demonstrates how to specify the name of the character set.
Response Object
The ASP Response object is used to send output to the user from the server. Its collections, properties, and methods are described below:
Collections
Collection
|
Description
|
|
Sets a cookie value. If the cookie does not exist, it will be created, and take the value that is specified
|
Properties
Property
|
Description
|
|
Specifies whether to buffer the page output or not
|
|
Sets whether a proxy server can cache the output generated by ASP or not
|
|
Appends the name of a character-set to the content-type header in the Response object
|
|
Sets the HTTP content type for the Response object
|
|
Sets how long (in minutes) a page will be cached on a browser before it expires
|
|
Sets a date and time when a page cached on a browser will expire
|
|
Indicates if the client has disconnected from the server
|
|
Appends a value to the PICS label response header
|
|
Specifies the value of the status line returned by the server
|
Methods
Method
|
Description
|
|
Adds a new HTTP header and a value to the HTTP response
|
|
Adds a string to the end of the server log entry
|
|
Writes data directly to the output without any character conversion
|
|
Clears any buffered HTML output
|
|
Stops processing a script, and returns the current result
|
|
Sends buffered HTML output immediately
|
|
Redirects the user to a different URL
|
|
Writes a specified string to the output
|
<html>
<body>
<%
response.write("Hello World!")
%>
</body>
</html>
formatting text with 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>
<html>
<body>
<%
dim name
name="Donald Duck"
response.write("My name is: " & name)
%>
</body>
</html>
array
<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>
Looping
<html>
<body>
<%
dim i
for i=1 to 6
response.write("<h" & i & ">Header " & i & "</h" & i & ">")
next
%>
</body>
</html
Time-based greeting using VBScript
<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>
<body>
<%
name = "Bill Gates"
response.write(ucase(name))
response.write("<br>")
response.write(lcase(name))
%>
</body>
</html>
<body>
<%
name = " W3Schools "
response.write("visit" & name & "now<br />")
response.write("visit" & trim(name) & "now<br />")
response.write("visit" & ltrim(name) & "now<br />")
response.write("visit" & rtrim(name) & "now")
%>
<body>
<%
sometext = "Hello Everyone!"
response.write(strReverse(sometext))
%>
</body>
</html>
<body>
<%
i = 48.66776677
j = 48.3333333
response.write(Round(i))
response.write("<br>")
response.write(Round(j))
%>
</body>
</html>
</body>
</html>
|