Link to home
Start Free TrialLog in
Avatar of SimonWilkins
SimonWilkins

asked on

multi line comments in asp

I'm trying to comment out blocks of code within ASP pages but i'm forced to do each line individually, is there a way to comment out blocks of text in one go for example in javascript this would be achieved like this

/*
come lines of code
and some more
*/

thanks for any help
Avatar of JeiPM
JeiPM

I've never been able to.  Are you using .NET?  I think you can with that, but I've yet to use it myself.
I have been trying to find something that explicitly says you cannot.  I've used ASP for a few years now and have never been able to unless using JScript.  Here's a link:

http://www.4guysfromrolla.com/webtech/top10/beg10.shtml

Microsoft explicitly states that muliple line comments are not supportes in ASP unless each line begins with a ' unless ur using jscript or .Net.

ASP Comment's
http://www.microsoft.com/technet/treeview/default.asp?url=/technet/prodtechnol/iis/plan/planasp.asp

.NET Comments
http://www.aspalliance.com/remas/ASP.NET/VFAQNET/Comments/

regards
syd
You can't with ASP/VBScript... it only supports single line comments like:

' This is a weak language...
' Don't you think?
' It would be nice if VBScript supported something like:
' /*
' Hey, this is a comment! Some scripting
' languages don't allow you to do this because
' they were poorly thought out!
' */

I'm not sure about VB.NET, since I avoid it like the plague in favor of the C-type syntax of C#, but all of the C-type syntax languages in .NET support multi-line comments, like:

/*
Man, I love .NET!
*/

With classic ASP/VBScript though, you're just stuck.
Hi SimonWilkins,

   Maybe you can try
<!--
  your code here ...
-->

sweetpillow
<!-- Your comments -->
This comment style is for HTML, not asp, which means if you use this you'll have to enclose it within script tags
%> <!-- Your comments --> <%


For vbscript it's the same as visual basic, there is not multi line comment available, you can opt to insert single line comments with using either single quote

'Your comment

   or a REM (stands for remark)

REM Your comment

VBScript is not case sensitive unlike java so rem instead is also functional as a comment line start tag
<% If 1 = 0 Then %>
<!--
lots
of
lines
of
VBscript
code
you
want
to
be
blocked
out!
-->
<% End If %>

It's cheeky, but you can see that it will work. The If statement will never get parsed, so the comment block will never get sent to the client, and you've also 'blocked' out all your code!! :-)

Sloppy fix for a sloppy language.
Heh, that's a clever way to do it, AlfaNoMore. If I was giving out the points, you'd get them. ;-)
ASKER CERTIFIED SOLUTION
Avatar of AlfaNoMore
AlfaNoMore

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of SimonWilkins

ASKER

OK AlfaNoMore ;-), you can have the points thanks everyone for the input. I think i'll use the solution given.
Hi guys, sorry but I'm just curious as to why the unnecessary if...then statement, yes it's true that
   if 1 = 0
will definitely return false so the statement will never be parsed, but y can't we just use the below?

%>
<!--
lots
of
lines
of
VBscript
code
you
want
to
be
blocked
out!
-->
<%

Without the if...then statement, it is excluded from server script blocks, recognized as HTML comment so client will never display it anyway. So wat for the extra conditional statement to slow down the loading of ur asp page?

Please enlighten me.

Cheers

IcE
Hi SimonWilkins,

Thats why I mention in my previous comment, u can try this

  Maybe you can try
<!--
 your code here ...
-->

because I always did the same thing as mention by AlfaNoMore in my program.

By using the advantage of asp code we can also reach our objectives eventhough as mention in ice69devil the code is for asp.

sweetpillow
Actually that _would_ show up in the HTML the way you did it, Ice69devil. :-)
First off u never use asp conditional code just so u can use multiple line of comments. It definately is extra work for the interpreter.(AlfaNoMore iam not trying to steal away ur points but it a bad programming practice)

Secondly Ice69devil's idea of <!-- will not work because the html will have comments all over -->

Spend a lil extra time and comment your asp pages properly using '. Trust me in the long run a well commented/documented asp page will help u a lot.

regards
syd
syd108, I totally agree with you, and do in fact comment out my code quite happily with those little ' tags.

Better to place your code in a sub. That way, if you want to block a load of code out, just rename the sub, or something:

Sub OLD_SubRoutine(params)
End Sub

Sub SubRoutine(params)
End Sub

Much neater.
Thnx for ur replies guys, yup i was aware of the <!--script comments--> will be visible on client side as messy HTML, perhaps i was more concerned with good programming habit and performance issues as syd as mentioned. Proper documentation is definitely a necessity.

Cheers to all

IcE
Rock on guys .NET rules
syd