ASP and HTML comment (in ASP)
ASP and HTML comment (in ASP)
By Michiel van Otegem
14 January 2002
It is always a good thing to put comments in your code about what it is doing. For trivial operations that may be overkill,
but when you are writing complex code doing something that may not be apparant from the code immediately,
it is imperative. Not only for others that may read your code, but for you as well. It is very likely that you will not remember
how you did something six months back.
Commenting your code can be done is several ways. First of all you can add comments in the HTML, outside the
ASP <% and %>, or <script> blocks.
You can add these comments as follows:
Within ASP you can also add comments, but in several ways. The first type of comments are the comments that can
be added within the script language you are using. In VBScript comments are preceded with ', whereas in
JScript they are preceded by //, or enclosed in /* and
*/. As is shown in the samples below.
<%@ Language=VBScript %>
<%
%>
<%@ Language=JScript %>
<%
%>
What you may not be aware of is that you can also use HTML comments within ASP script blocks! So the following
will work:
<%
%>
The comments inside your ASP will not break the code. They will also not show up in the client browser. When you
use <script runat="server"> blocks however, the comments are written to the client browser
just as if they are HTML comments outside ASP.
|