Wednesday 19 October 2005 — This is 19 years old. Be careful.
Looking for basic information about ASP.NET syntax, I found this description of Server-Side Comment Syntax. It explains:
Server-side comments enable page developers to prevent server code (including server controls) and static content from executing or rendering. The following sample demonstrates how to block content from executing and being sent down to a client.
There you have it: the point of a comment is to prevent a chunk of code from executing. There’s no mention of using comments to communicate with other developers. This helps explain a number of Daily WTF’s!
Comments
"If it's hard to write, it should be hard to read and even harder to change."
Note: the text does make an important, if muddled, point that everything between <%-- and --%> is filtered out. In other words, unlike HTML comments, these comments aren't sent to the client. An important distinction if the comments contain proprietary information -- or snide remarks. ;-)
If you have a server control in an ASPX page, and you comment it out with <!-- -->, the control will still be rendered on the server into the resulting HTML (which will be hidden on the client because of the comment tags), and any side-effects it might have (database updates, web-service calls, etc) will still take place. With the <%-- --%> comments, the server-side execution won't happen.
Add a comment: