ASP mainly has five built-in (built-in) objects: Server, Request, Response, application and session. Now we'll explain them by example. The first is the most commonly used response object.
Example 1 using response to output HTML documents in a Web page
You can enter the above code in FrontPage Editor, or WordPad, Notepad, and so on, and then save as example1.asp, the file name can be anything else, but the extension (or suffix) must be. ASP. The previous example uses the "write function" of the response object to send HTML code to the client's browser, and the browser on the client computer displays the following list:
· My name is Jack. · I am from America. · and I love.
|
In fact, these HTML code can be written directly in the ASP file, and do not have to use Response.Write to output, in general, variables or some of the changed data to use Response.Write to output. In addition, we can use <%= data or variable%> to output information, and its effect is equivalent to Response.Write.
Example 2 uses response and <%= data%> to output the calculated results from 1 to 100 in the Web page
The above example does not indicate that the use of VB Script scripting language, because the ASP default is VB Script, if you want to use Java script, you can in the top line of ASP in the statement
specified. Note that there must be a space between the symbol "@" and "LANGUAGE". Once you have indicated it, you can use JavaScript as you please. For example 2, we can use JavaScript to do this.
Example 3 uses JavaScript and <%= data%> to output calculations from 1 to 100 in a Web page
in this case, we used a flag pair and marked the use of the JavaScript scripting language, unlike the HTML document, where the statement runat= "server" in the flag pair indicates that the script is running on the server side, Instead of being routed to the client's browser, the explanation runs later. To prove this is simple, view the source code in the browser, you will not see the
<script language= The Code section of the "JScript" runat= "Server" >......</script> and <%......%>
|
In addition to the "Write" function, Response also has "End method": Response.End. It is used to end the output of a Web page and the running of server-side scripting programs. Readers can attempt to use this "End method" themselves. Okay, next tutorial we'll talk about the powerful request-for-build (built-in) object in ASP.