开发者

Server-side comments: What's the equivalent of <%-- --%> in ASP Classic?

What's the equivalent of <%-- --%> in ASP Classic?

I have to modify a legacy ASP application and I'd like to comment out a block of HTML:

<td>
    some table cell I'd like to comment out, including
    some <%= inli开发者_JS百科neServerSideVBScriptExpressions() %>
</td>

Wrapping everything in <%-- ... --%>, as I'd do in ASP.NET, doesn't work and results in the compilation error "Expected statement". HTML comments <!-- ... --> are not an option either, since the inline ASP expressions would get evaluated and fail.


Try this:-

<!-- METADATA  
  Your comments here
-->

The METADATA indicates to the ASP processor that this is a comment that does not need to be sent to the client.


There's no "built-in" way to do block comments in ASP Classic. You have to put a ' before each line you don't want to run.


Here is how I can easily comment out an entire block of mixed code:

<% If False Then %>
  <html stuff></html stuff>
  <% more asp stuff %>
<% End If %>

If I had to do this many times I would make some kind of macro for my computer to do this via hotkey.


Apostrophe-style comments are supported in VBScript. They might work here.

These are removed when the script is processed, and aren't sent to the browser.

<%
   'This line and the following two are comments.
   'The function below does something ineluctable.
   'So don't mess with it.
   SomeFunction()
%>

Here is a source for this.


This is what source control is for. Just delete the code and mark it appropriately when you check it in so you can find the snippet later if you need it.


@Heinzi: Since you can't use Joel Coehoorn's excellent solution, you could also use something like

<%
Dim blnDebug : blnDebug = True

If NOT blnDebug Then
    ' Display mixed HTML/ASP code
%>
HTML, HTML .. <%=someASPfunction() %> .. more HTML
<%
End If
%>

...and then hack away at the file and when you're ready to turn on the code you've effectively "commented out", just set blnDebug to False. It beats putting apostrophes in front of every in-line code call for me.


I know that you can do that in Dreamweaver; I saw my colleague doing it. But I am using Visual Studio or Notepad++ most of time, and this feature is not working there.

So I am commenting multiple lines using special pasting of a single quote, ', by pressing:

Shift + Alt + arrow down or up, then adding a single quote, '.

And the same for uncommenting the ' by selecting all 's in all lines and then delete.

Server-side comments: What's the equivalent of <%-- --%> in ASP Classic?

Server-side comments: What's the equivalent of <%-- --%> in ASP Classic?


The way I always comment out is using:

<%'=Var%>


I'm using a similar solution to @Vasily Hall answer

I'm using Sublime so I need to visualise the comment to my IDE too

<% if 1 = 2 then 'comment %>
  <!--div>
   ...
   multicomment goes here
   ...
  </div -->
<% end if 'end comment %>


As a personal use for local tests where you are not afraid of leaking codes, you can close the asp tag using %><!-- and continue executing codes using --><%

<%
first block to execute
%><!-- 

second block to comment out

--><%
Third block to execute
%>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜