Recommended: ASP Programming--Newbie's Going to the Road: Introduction to ASP Technology ASP is the abbreviation of Microsoft Active Server Pages. ASP is a server-side scripting platform developed by Microsoft. ASP is included in IIS. Currently, the highest version of IIS is version 5.0. Through ASP, we can combine HTML web pages and ASP instructions
You cannot directly obtain the source code of ASP through the View-Source File option on the browser (because the ASP code and script program must be interpreted and executed on the server in advance; then, the server will send the result after the ASP code is interpreted and sent to the browser in the form of HTML data stream), so what you see is only converting ASP into HTML form content, and you cannot directly obtain the ASP source code.
In our ASP tutorial, each example will show the source code of ASP, which will help you understand how ASP works.
An ASP file usually contains HTML tags, and sometimes very similar to an HTML file. However, the ASP file (in addition to containing HTML tags), it can also include the server's scripting program, which must be written between the <% and %> bound symbols (the server will know that the following is the ASP program, <% means the start of the ASP program, and %> means the end of the ASP program). ASP scripting program is interpreted and executed on the server side. These scripting programs can include all the expressions, statements, programs and valid operators you want to use.
Output the result to the browser
| The following is the quoted content: <html> <body> <% response.write(Hello World!) %> </body> </html> |
The following example is exactly the same as the Response.Write directive. It is a simplified form of the Response.Write directive, and it will also bring Hello World! This passage is sent to the browser:
| The following is the quoted content: <html> <body> <%=Hello World!%> </body> </html> |
VBScript Script
You can use some script statements when writing ASP code. The default script statement of ASP is VBScript:
| The following is the quoted content: <html> <body> <% response.write(Hello World!) %> </body> </html> |
The above program will display Hello World on the web page!
JavaScript Script
If you need to use JavaScript scripts as the default script statement to write some special ASP web pages, then you need to insert a statement at the top of the web page to specify the default script statements for the entire web page, as follows:
| The following is the quoted content: <%@ language=javascript%> <html> <body> <% Response.Write(Hello World!) %> </body> </html> |
Note: The VBScript script statement we mentioned earlier is a script statement that is not sensitive to letter case, namely: response.write / Response.Write / ReSpoNSe.WRiTe, all of which are valid; however, if you write ASP code in JavaScript script statements, you have to distinguish the case of letters, because JavaScript script statement is a script statement that is sensitive to letter case, that is: Response.Write is valid, and response.write / ReSpoNSe.WRiTe are all invalid statements. Therefore, friends must pay special attention when writing.
Other scripting languages
ASP directly supports VBScript script programs and JScript (Microsoft's own JavaScript script execution program). If you need to use other languages, such as PERL, PEXX or Python, then you must install the driver engine of these script programs.
Important tip: Because script programs are executed on the server side, the browser does not need to install script programs to display ASP files.
Variables are used to store required information
If you declare a variable externally in a subroutine (such as sub, function in VBScript), then all script programs in the ASP file can modify the value of this variable; if you declare a variable internally in a subroutine, then every time the subroutine is executed, the value of this variable will be established or cancelled.
The life cycle of variables
If you declare the value of a variable outside of a subroutine, its value can be accessed and changed by all script programs in the ASP file.
If you declare a variable inside a subroutine, then every time the subroutine is executed, the value of this variable will be established or cancelled; while script programs outside this subroutine cannot access or change the value of this variable.
If you want the declared variables to be called by multiple ASP files, you must declare the values of these variables in the form of Session variables or Application variables.
Session variables
The Session variable is used to store information of a single user, and all pages contained in the same application can access it. We often store common information such as name, id number, and preferences in Session variables.
Application variables
Similarly, Application variables can be accessed by all pages contained in the same application. Application variables are usually used to store information about all users under a specific request.
Share: ASP instance: A simple ASP component-free upload class A simple ASP component-free upload class is sent out for everyone to see. Can do experiments! The following is the quoted content: <%@ language=javascript%><%va