Through learning the Request object, we can understand that the Request object is used by the server to obtain the client's information.
But as a server and client interact, is it still lacking to send information to the client? The object Response assumes this responsibility.
The object responsible for passing information to the user is Response, which can respond dynamically to client requests and return the dynamically generated response results to client browser.
1. Response.write
In Response, write method is the most frequently used one. Write is to write: 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>" %> |
The information displayed is followed by the response.write, which can be included in brackets or written directly (note that there are spaces between the response.write).
The written string information or HTML code is related to it, and it is included in quotes; while the functions or variables of ASP itself are not needed, just use them directly.
And whether it is connected between string information, HTML code, functions or variables, the & number is used (for vbscript)
The above encounters a random function rnd(), which returns a value less than 1 but greater than or equal to 0.
It should be noted that before calling Rnd, the random number generator is initialized with a parameterless Randomize statement, which has a seed based on the system timer.
If Randomize is missing, random seeds cannot be generated.
The following is an example that uses a random function to produce a random background color effect:
[Ctrl+A All selections are given for copying: you can modify some codes first, and then click Run]
Of course to generate random integers in the specified range, please use the following formula:
Int((upperbound - lowerbound + 1) * Rnd + lowerbound)
Here, upperbound is the upper bound of this range, and lowerbound is the lower bound within this range.
[Ctrl+A All selections are given for copying: you can modify some codes first, and then click Run]
Random functions are very useful when doing the exam system. Of course, you can also use them to draw the prize by yourself. Just get the first prize and get the first prize and I can just get it.