Server-side comments: What's the equivalent of

2019-02-16 08:02发布

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 <%= inlineServerSideVBScriptExpressions() %>
</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.

10条回答
老娘就宠你
2楼-- · 2019-02-16 08:26

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.

查看更多
祖国的老花朵
3楼-- · 2019-02-16 08:29

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.

查看更多
趁早两清
4楼-- · 2019-02-16 08:30

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.

查看更多
老娘就宠你
5楼-- · 2019-02-16 08:30

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.

查看更多
贪生不怕死
6楼-- · 2019-02-16 08:37

Another way to block comment your code is to escape back out of the VBScript at the point where you want the comment to be and insert standard HTML comments, like so...

<%
Dim myVar
Do
    SomeStuff args
Until fedUp
%>
<!--                            <== Start here
BlockCommentedOut myVar
myVar = 123
-->                             <== End here
<%
'In line comments.
For i = 0 To 150
    DoStuff myVar
Next
%>
查看更多
对你真心纯属浪费
7楼-- · 2019-02-16 08:38

The way I always comment out is using:

<%'=Var%>
查看更多
登录 后发表回答