Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

multi line comments in asp

Posted on 2003-03-06
17
Medium Priority
?
4,998 Views
Last Modified: 2009-07-19
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
0
Comment
Question by:SimonWilkins
  • 3
  • 3
  • 3
  • +4
17 Comments
 
LVL 1

Expert Comment

by:JeiPM
ID: 8081493
I've never been able to.  Are you using .NET?  I think you can with that, but I've yet to use it myself.
0
 
LVL 1

Expert Comment

by:JeiPM
ID: 8081699
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

0
 
LVL 2

Expert Comment

by:syd108
ID: 8081845
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
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 4

Expert Comment

by:whammy
ID: 8085077
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.
0
 

Expert Comment

by:sweetpillow
ID: 8085261
Hi SimonWilkins,

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

sweetpillow
0
 

Expert Comment

by:Ice69devil
ID: 8086584
<!-- 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
0
 
LVL 9

Expert Comment

by:AlfaNoMore
ID: 8086951
<% 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.
0
 
LVL 4

Expert Comment

by:whammy
ID: 8088769
Heh, that's a clever way to do it, AlfaNoMore. If I was giving out the points, you'd get them. ;-)
0
 
LVL 9

Accepted Solution

by:
AlfaNoMore earned 80 total points
ID: 8088818
Sweet :-)
0
 

Author Comment

by:SimonWilkins
ID: 8088843
OK AlfaNoMore ;-), you can have the points thanks everyone for the input. I think i'll use the solution given.
0
 

Expert Comment

by:Ice69devil
ID: 8092693
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
0
 

Expert Comment

by:sweetpillow
ID: 8099805
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
0
 
LVL 4

Expert Comment

by:whammy
ID: 8099817
Actually that _would_ show up in the HTML the way you did it, Ice69devil. :-)
0
 
LVL 2

Expert Comment

by:syd108
ID: 8103079
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
0
 
LVL 9

Expert Comment

by:AlfaNoMore
ID: 8103156
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.
0
 

Expert Comment

by:Ice69devil
ID: 8103304
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
0
 
LVL 2

Expert Comment

by:syd108
ID: 8103342
Rock on guys .NET rules
syd
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:   The Exchange of informatio…
Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
The Relationships Diagram is a good way to get an overall view of what a database is keeping track of. It is also where relationships are defined. A relationship specifies how two tables connect to each other. As you build tables in Microsoft Ac…
Suggested Courses

564 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question