Friday, March 14, 2008

How do I comment blocks of ASP code?

Comments are notations that you can make on your web pages within an ASP script block that will not be interpreted or output on the displayed web page(s). For all intents and purposes, they are hidden from your site visitors since they cannot view the ASP source code for your web pages. This allows you to make comments inside your code that will help explain exactly what your code is doing.
Active Server Pages use the quote character (') to define comments. This comment is a "line comment", meaning that it will comment out everything following it up until the end of the line. There is no multiline comment in ASP. In order to comment multiple lines, each line must be preceded by a quote (').
Besides not having any support for multi-line comments, your ASP comments will not work if you place them within a string. This is because the interpreter will think that your apostrophe is a part of the string and not a comment. Below is an example of this happening. Again, the following is an example of what not to do!

No comments: