Asp Tutorial:ASP and HTML comment

Home arrow .NET Tutorials arrow ASP.NET arrow Asp Tutorial:ASP and HTML comment
Asp Tutorial:ASP and HTML comment Print E-mail
User Rating: / 15
PoorBest 
Contributed by Howell   
Sunday, 11 June 2006
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:

<!--this is HTML comment-->
<!--this is HTML comment
spanning multiple lines
-->

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 &apos;, whereas in JScript they are preceded by //, or enclosed in /* and */. As is shown in the samples below.

<%@ Language=VBScript %>
<%
'this is VBScript comment
%>

<%@ Language=JScript %>
<%
//this is JScript comment
/*
this is multi-line
JScript comment
*/
%>

What you may not be aware of is that you can also use HTML comments within ASP script blocks! So the following will work:

<%
<!--this is HTML comment inside ASP-->
<!--this is HTML comment inside ASP
spanning multiple lines
-->
%>

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. How ASP.NET will deal with this is something I will look into some other time.

Last Updated ( Sunday, 11 June 2006 )

  home              contact us

 

©2006-2012 DeveloperZone.biz   All rights reserved     powered by Mambo Designed by Siteground