ASP Syntax
The syntax of ASP is straightforward and based on VBScript or JScript. It uses embedded server-side script tags <% ... %>
to execute server-side logic within an HTML document.
Key Topics
Basic Syntax
Example
<%
Dim message
message = "Hello, ASP!"
Response.Write(message)
%>
Explanation: This example declares a variable, assigns it a value, and uses Response.Write
to display the message dynamically on the web page.
Using Response.Write
Example
<%
Response.Write("Current Time: " & Now())
%>
Explanation: The Response.Write
method is used to output text or data to the client. This example displays the current date and time dynamically.
Adding Comments
Example
<%
' This is a single-line comment
Response.Write("ASP Syntax Example")
%>
Explanation: Comments in VBScript start with a single quote ('
). They are ignored during execution and are useful for documentation and code clarity.
Key Takeaways
- ASP uses
<% ... %>
tags for embedding server-side logic. - The
Response.Write
method outputs data dynamically to the web page. - Comments improve code readability and are ignored by the server during execution.