Commenting code in ASP Classic

十年热恋 提交于 2021-02-08 12:18:57

问题


The way I know of hashing out code within ASP Classic is <%-- --%>. Would this be correct? Or is there another way?


回答1:


Use a single quote, like:

' This is comment

ASP Classic uses the VBScript/Visual Basic language, and a single quote is commenting in that; <%-- is nothing (I am not 100% sure though).




回答2:


Beside ', you can comment lines in the old school way:

 REM Response.Write "Ignore this line"

Which is same with

 ' Response.Write "Ignore this line"



回答3:


Assuming you mean that you have large block of inline code like the below you want to disable:

<%
    CallSomething()
    DoSomething()
    Response.Write("all done")
%>

Then either comment out each line as described in this other answer or other approach is:

  1. Create a dummy, empty file called "dummy.asp" and place it in the same folder.
  2. Change the code block to this:

    <script language="vbscript" runat="server" src="dummy.asp">
        CallSomething()
        DoSomething()
        Response.Write("all done")
    </script>
    

    Note: you need to change only the <% and %>, all other lines can stay intact. Having a src in the script tag will cause the Classic ASP engine to take the file contents instead of taking the script block contents.

Then when you want to uncomment, either do it for each line or put back the <% and %>.




回答4:


The question says... ASP classic.....

All the above answers are good, but specific to VBScript.

But a classic ASP file can also contain HTML and Javascript

Commenting VBScript code in a classic ASP file:

Refer any of the approved answers.

Commenting HTML code in a classic ASP file:

Refer https://www.w3schools.com/TAGS/tag_comment.asp

Commenting Javascript code in a classic ASP file:

Refer https://www.w3schools.com/js/js_comments.asp




回答5:


This is the best way to comment out large blocks of code:

<%if 1=2 then%>

html or other code here

<%end if%>


来源:https://stackoverflow.com/questions/16939281/commenting-code-in-asp-classic

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!