可能重複:
What's the difference between <%# %> and <%= %>?
<%$, <%@, <%=, <%# … what's the deal?<%:和<%=和<%#在aspx中有什麼區別?
我道歉,如果這是重複的,但它是僵硬難以谷歌。
可能重複:
What's the difference between <%# %> and <%= %>?
<%$, <%@, <%=, <%# … what's the deal?<%:和<%=和<%#在aspx中有什麼區別?
我道歉,如果這是重複的,但它是僵硬難以谷歌。
<%:
是.NET 4.0的新增功能 - 它相當於HttpUtility.HtmlEncode(Response.Write())
。
<%=
較舊,僅代表Response.Write()
。
<%#
是binding expression。
Here's對他們很好的文章。總結:
Page指令
<%@ Page Language="C#" %>
渲染代碼
<% Response.Write("Hello World!"); %>
<%= SayHello("Ahmed") %>
<%: DateTime.Now.ToString() %>
表達式語法
<%$ ConnectionStrings:ConnStrFromWebConfig %>
<%$ AppSettings:ValueFromWebConfig %>
<%$ Resources:Resource, Arabic %>
<%$ RouteValue:year %>
<%$ YourExpressionPrefix : Any %>
數據綁定語法
<%# Eval("Name") %>
<%# Bind("Name") %>
<%# XPath ("Name") %>
註釋服務器
<%-- <asp:Label runat="server" Text="Label"></asp:Label>-- %>
也http://stackoverflow.com/questions/197047/what-is-the-difference-between-and – Oded 2012-02-22 16:23:50
和http://stackoverflow.com/questions/160097/whats與其他人之間的差異 – 2012-02-22 16:24:01
乾杯,恥辱,你不能使用搜索搜索<%...即使建議列表中沒有這些。你究竟是怎麼找到它們的? :)我會關閉作爲愚蠢 – NibblyPig 2012-02-22 16:25:54