2010-09-28 101 views
8

我們在哪裏使用<%@ %><%= %><%# %>等 什麼其他asp標籤可以添加到asp.net網頁?如何在ASP.NET網頁中嵌入代碼塊?

+0

可能重複的[ASP.NET「特殊」標記](http://stackoverflow.com/questions/649428/asp-net-special-tags) – 2010-09-28 11:47:23

回答

0
<%@ %> - page directives, Register control 
<%= %> - for the server code 
<%# %> - for the eval kind of function its also for the server code 
+0

那麼爲什麼這不給任何輸出Text ='<%= DateTime.Now.ToShortTimeString()%>' – ppp 2010-09-28 11:50:11

+0

@ppp它將值賦給控件表單內聯編碼 – 2010-09-28 11:52:55

+0

@Rana表示?如何使用此標籤將當前日期時間的標籤值設置爲? – ppp 2010-09-28 11:56:30

15

<%%>短手:所述<%%>是服務器端代碼內

<script runat="server"> 
</script> 

點兒。

其他變型也是快捷鍵:

  • <%@%>是頁面directrive
  • <%=%>是短期的Response.Write
  • <%:%>短爲Response.Write,加入HTML編碼(與.NET 4.0引入)
  • <%#%>是結合表達

This page對所有這些都是很好的參考。