Advanced ASP Programming (5): built-in object Response
Source: Internet
Author: User
Through learning the Request object, we can understand that the Request object is used by the server to obtain client information.
But as a server to interact with the client, is there still a lack of server to send information to the client? The object Response assumes this responsibility.
The object that is responsible for transmitting information to the user is Response. It can dynamically respond to client requests and return the dynamically generated Response results to the client browser.
1. Response. write
In Response, the write method is the most frequently used. write is to write the specified string to the current HTTP output.
1. write. asp
<%
Response. write ("hello, world" & "<br> ")
Randomize
Response. write "any number is" & rnd () & "<br>"
%>
Response. write is followed by the displayed information, which can be included in parentheses or written directly (note that there is a space between response. write ).
The written string information or HTML code is related and enclosed in quotation marks. ASP functions or variables are not required and can be used directly.
In addition, no matter the string information, HTML code, functions, or variables are connected using the & sign (for vbscript)
The preceding random function rnd () returns a value smaller than 1 but greater than or equal to 0.
Before calling Rnd, you must first use the Randomize statement without parameters to initialize the random number generator, which has a seed based on the system timer.
If Randomize is missing, the random seed cannot be generated.
The following example uses a random function to produce a random background color:
<Script language = vbs>
Randomize' first, Randomize generates random seeds.
Suij = rnd () 'and then assign the function value to suij.
Suij = replace (suij, ".", "9") 'then converts the decimal point in the suij variable to 9
Suij = left (suij, 6) 'and then take the left 6 digits in the variable
Document. write "<body bgcolor = #" & suij & ">" 'is applied to the background color.
</Script>
[Ctrl + A Select All tips: You can modify some code and then press run]
Use the following formula to generate a random integer in the specified range:
Int (upperbound-lowerbound + 1) * Rnd + lowerbound)
Here, upperbound is the upper bound of this range, while lowerbound is the lower bound of this range.
<Script language = vbs>
Do Until choose = vbNo
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service