aspx文件服务器端注释是,详解ASP.NET注释语句及服务器注释

服务器端ASP.NET注释语句

允许您将ASP.NET注释语句包括在 .aspx 文件的正文中。服务器端注释元素的开始标记和结束标记之间的任何内容,不管是 ASP.NET 代码还是文本,都不会在服务器上进行处理或呈现在结果页上。

备注

ASP.NET服务器端注释块与传统的语言特定注释块具有相同的用法(包括文档和测试)。

和 块中,可以使用正用于编码的语言的注释语法。

如果在 块中使用服务器端ASP.NET注释块,则会出现编译错误。

开始和结束ASP.NET注释标记可以出现在同一行代码中,也可以由许多被注释掉的行隔开。

服务器端注释块不能被嵌套。

ASP.NET注释示例

下面的示例说明被注释掉的 HtmlButton 控件。

Click here for enlightenment!

< SPAN>button>

--%>

JScript 注释

单行 JScript 注释以两个正斜杠 (//) 开始。以下是单行注释(后跟一行代码)的一个示例。// This is a single-line comment.

aGoodIdea ="Comment your code for clarity.";

多行 JScript 注释以正斜杠和星号 (/*) 开头,以相反的顺序 (*/) 结束。

/*

This is a multiline comment that explains the preceding code statement.

The statement assigns a value to the aGoodIdea variable. The value,

which is contained between the quote marks, is called a literal. A

literal explicitly and directly contains information; it does not

refer to the information indirectly. The quote marks are not part

of the literal.

*/

如果试图在一个多行注释中嵌入另一个多行注释,JScript 将以一种意想不到的方式解释生成的多行注释。标记嵌入的多行注释结尾的 */ 将被解释为整个多行注释的结尾。因此,在嵌入的多行注释后面的文本将被解释为 JScript 代码,并可能生成语法错误。

在下面的示例中,由于 JScript 将最里面的 */ 解释为最外面注释的结尾,因此第三行文本将被解释为 JScript 代码:/* This is the outer-most comment

/* And this is the inner-most comment */

...Unfortunately, JScript willtryto treat all ofthisas code. */

建议将所有ASP.NET注释语句编写为单行注释的块。这样就允许随后用一个多行ASP.NET注释来注释大段代码。// This is another multiline comment, written as a series of single-line comments.

// After the statement is executed, you can refer to the content of the aGoodIdea

// variable by using its name, as in the next statement, in which a string literal is

// appended to the aGoodIdea variable by concatenation to create a new variable.

varextendedIdea = aGoodIdea +" You never know when you'll have to figure out what it does.";

或者还可以使用条件编译安全有效地注释大段代码。

【编辑推荐】

【责任编辑:彭凡 TEL:(010)68476606】

点赞 0

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值