设为首页收藏本站language→→ 语言切换

鸿鹄论坛

 找回密码
 论坛注册

QQ登录

先注册再绑定QQ

查看: 1797|回复: 1
收起左侧

菜鸟课堂:详解ASP.NET注释语句及服务器注释

[复制链接]
发表于 2010-2-25 10:53:22 | 显示全部楼层 |阅读模式
<p >服务器端ASP.NET注释语句 <p ><p >允许您将ASP.NET注释语句包括在 .aspx 文件的正文中。服务器端注释元素的开始标记和结束标记之间的任何内容,不管是 ASP.NET 代码还是文本,都不会在服务器上进行处理或呈现在结果页上。<p ><p ><%-- commented out code or content --%><p >备注<p ><p >ASP.NET服务器端注释块与传统的语言特定注释块具有相同的用法(包括文档和测试)。<p ><p >在 和 块中,可以使用正用于编码的语言的注释语法。<p ><p >如果在 块中使用服务器端ASP.NET注释块,则会出现编译错误。<p ><p >开始和结束ASP.NET注释标记可以出现在同一行代码中,也可以由许多被注释掉的行隔开。<p ><p >服务器端注释块不能被嵌套。<p ><p >ASP.NET注释示例<p ><p >下面的示例说明被注释掉的 HtmlButton 控件。<p ><p ><%-- <button runat="server" id="MyButton" OnServerClick="MyButton_Click">              Click here for enlightenment!         button>  --%><p >JScript 注释<p ><p >单行 JScript 注释以两个正斜杠 (//) 开始。以下是单行注释(后跟一行代码)的一个示例。<p ><p >// 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.  */ <p >如果试图在一个多行注释中嵌入另一个多行注释,JScript 将以一种意想不到的方式解释生成的多行注释。标记嵌入的多行注释结尾的 */ 将被解释为整个多行注释的结尾。因此,在嵌入的多行注释后面的文本将被解释为 JScript 代码,并可能生成语法错误。<p ><p >在下面的示例中,由于 JScript 将最里面的 */ 解释为最外面注释的结尾,因此第三行文本将被解释为 JScript 代码:<p ><p >/* This is the outer-most comment  /* And this is the inner-most comment */ ...Unfortunately, JScript will try to treat all of this as code. */ <p >建议将所有ASP.NET注释语句编写为单行注释的块。这样就允许随后用一个多行ASP.NET注释来注释大段代码。<p ><p >// 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.  var extendedIdea = aGoodIdea + " You never know when you'll have to figure out what it does."; <p >或者还可以使用条件编译安全有效地注释大段代码。<p ><p >< align=right></P><p align="center"></p></p>
发表于 2012-3-30 20:23:32 | 显示全部楼层
沙发 2012-3-30 20:23:32 回复 收起回复
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 论坛注册

本版积分规则

QQ|Archiver|手机版|小黑屋|sitemap|鸿鹄论坛 ( 京ICP备14027439号 )  

GMT+8, 2024-5-4 11:00 , Processed in 0.060184 second(s), 10 queries , Redis On.  

  Powered by Discuz!

  © 2001-2024 HH010.COM

快速回复 返回顶部 返回列表