In the browser, you cannot see the ASP source code by looking at the source code. You can only see the result output by the ASP file, and those are just pure HTMLs. This is because the script was executed in the server before the result was returned to the browser.
Example:
Use ASP to write text
<html>
<body>
<%
response.write (Hello World!)
%>
</body>
</html>
Add HTML to the text
<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>
Basic ASP grammar rules
Under normal circumstances, the ASP file also contains HTML tags, similar to HTML files. However, the ASP file can also include server -side scripts, which are surrounded by <%and%>. The server script is executed on the server side, which can contain legal expression, statement, or operators.
Write output to the browser
Response.write command is used to write output to the browser. The following example conveys a piece of text to the browser: Hello World.
<html>
<body>
<%
response.write (Hello World!)
%>
</body>
</html>
There is also a brief method of the response.write command. The following examples and the above example are equivalent:
<html>
<body>
<%= Hello World!%>
</body>
</html>
Vbscript
You can use several types of script language in ASP. However, the default script language is VBScript:
<html>
<body>
<%
response.write (Hello World!)
%>
</body>
</html>
The above example also wrote the text hello world in the body of the document!.
Javascript
If you need to use JavaScript as the default script language of a specific page, you must insert a line of language setting at the top of the page:
<%@ Language = javascript%>
<html>
<body>
<%
Response.write (Hello World!)
%>
</body>
</html>
Note: Unlike VBScript-JavaScript is sensitive to lowercase. So you need to write ASP code based on JavaScript need to use different large and small letters.
Other script language
The cooperation between ASP and VBScript and JScript is native. If you need to write scripts in other languages, such as Perl, Rexx, or Python, you must install the corresponding footsteps.
Important matters: Because the script is executed on the server side, the browser that shows the ASP file does not need to support the script at all.