自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

詳解ASP.NET注釋語句及服務(wù)器注釋

開發(fā) 后端
本文將介紹ASP.NET注釋語句,包括服務(wù)器端的注釋語句。良好的注釋能幫助開發(fā)人員更好的理解程序代碼,希望本文能對大家有所幫助。

服務(wù)器端ASP.NET注釋語句

允許您將ASP.NET注釋語句包括在 .aspx 文件的正文中。服務(wù)器端注釋元素的開始標(biāo)記和結(jié)束標(biāo)記之間的任何內(nèi)容,不管是 ASP.NET 代碼還是文本,都不會在服務(wù)器上進行處理或呈現(xiàn)在結(jié)果頁上。

  1. <%-- commented out code or content --%> 

備注

ASP.NET服務(wù)器端注釋塊與傳統(tǒng)的語言特定注釋塊具有相同的用法(包括文檔和測試)。

在 和 <% %>塊中,可以使用正用于編碼的語言的注釋語法。

如果在 <% %>塊中使用服務(wù)器端ASP.NET注釋塊,則會出現(xiàn)編譯錯誤。

開始和結(jié)束ASP.NET注釋標(biāo)記可以出現(xiàn)在同一行代碼中,也可以由許多被注釋掉的行隔開。

服務(wù)器端注釋塊不能被嵌套。

ASP.NET注釋示例

下面的示例說明被注釋掉的 HtmlButton 控件。

  1. <%-- <button runat="server" id="MyButton" OnServerClick="MyButton_Click"> 
  2.              Click here for enlightenment!  
  3.        button> 
  4.  --%>  

JScript 注釋

單行 JScript 注釋以兩個正斜杠 (//) 開始。以下是單行注釋(后跟一行代碼)的一個示例。

  1. // This is a single-line comment.  
  2. aGoodIdea = "Comment your code for clarity.";  
  3. 多行 JScript 注釋以正斜杠和星號 (/*) 開頭,以相反的順序 (*/) 結(jié)束。  
  4. /*  
  5. This is a multiline comment that explains the preceding code statement.  
  6. The statement assigns a value to the aGoodIdea variable. The value,  
  7. which is contained between the quote marks, is called a literal. A  
  8. literal explicitly and directly contains information; it does not  
  9. refer to the information indirectly. The quote marks are not part  
  10. of the literal.  
  11. */ 

如果試圖在一個多行注釋中嵌入另一個多行注釋,JScript 將以一種意想不到的方式解釋生成的多行注釋。標(biāo)記嵌入的多行注釋結(jié)尾的 */ 將被解釋為整個多行注釋的結(jié)尾。因此,在嵌入的多行注釋后面的文本將被解釋為 JScript 代碼,并可能生成語法錯誤。

在下面的示例中,由于 JScript 將最里面的 */ 解釋為最外面注釋的結(jié)尾,因此第三行文本將被解釋為 JScript 代碼:

  1. /* This is the outer-most comment  
  2. /* And this is the inner-most comment */ 
  3. ...Unfortunately, JScript will try to treat all of this as code. */ 

建議將所有ASP.NET注釋語句編寫為單行注釋的塊。這樣就允許隨后用一個多行ASP.NET注釋來注釋大段代碼。

  1. // This is another multiline comment, written as a series of single-line comments.  
  2. // After the statement is executed, you can refer to the content of the aGoodIdea  
  3. // variable by using its name, as in the next statement, in which a string literal is  
  4. // appended to the aGoodIdea variable by concatenation to create a new variable.  
  5. var extendedIdea = aGoodIdea + " You never know when you'll have to figure out what it does."

或者還可以使用條件編譯安全有效地注釋大段代碼。

【編輯推薦】

  1. 淺析ASP.NET Web 安全性
  2. ASP.NET的Session State
  3. 淺析IsPostBack屬性ASP.NET
  4. ASP.NET構(gòu)架與安全機制
  5. 概述ASP.NET水晶報表
責(zé)任編輯:彭凡 來源: CSDN
相關(guān)推薦

2009-07-29 13:42:25

ASP.NET注釋

2009-08-04 13:10:05

ASP.NET服務(wù)器控

2009-08-10 14:08:15

ASP.NET服務(wù)器控ASP.NET組件設(shè)計

2009-08-03 18:00:00

ASP.NET服務(wù)器控

2011-07-12 15:17:02

ASP.net服務(wù)器控件

2009-08-04 17:18:37

2009-07-28 10:43:23

Web服務(wù)器ASP.NET

2009-08-10 14:25:33

ASP.NET服務(wù)器控

2009-08-04 13:39:43

ASP.NET 2.0

2009-08-04 15:13:38

2009-07-27 12:56:27

控件CheckBoxLASP.NET服務(wù)器

2009-07-29 16:08:07

ASP和ASP.NET

2009-08-06 14:16:04

ASP.NET服務(wù)器控

2009-07-29 12:55:44

ASP.NET身份驗證

2009-07-28 16:57:50

ASP.NET Ses

2009-07-22 16:25:41

ASP.NET AJA

2009-07-24 10:14:22

ASP.NET開發(fā)

2009-08-05 11:14:33

ASP.NET ISA

2009-08-06 14:42:54

ASP.NET服務(wù)器控

2009-08-01 20:59:08

ASP.NET服務(wù)器控ASP.NET服務(wù)器ASP.NET
點贊
收藏

51CTO技術(shù)棧公眾號