?
Solved

multi line comments in asp

Posted on 2003-03-06
17
Medium Priority
?
4,701 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Industry Leaders: 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!

 
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

[Webinar] How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them.

Question has a verified solution.

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

I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…

764 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