你能告诉之间与其中的差别;%=%>中<%#%>和<%$%> ASP.NET EX pressions?你能、差别、LT、gt

由网友(适者生存,-)分享简介:您可以简单地列出之间的&LT的差异;%=%> ,<%#%> 和<%$%> 通过给一个简单的例子也许有,只需要那些EX pressions之一使用?解决方案 < %%> <%this.CallMethod()%> - 的基本code座。&其中;%=%GT; &L...

您可以简单地列出之间的&LT的差异;%=%> <%#%> <%$%> 通过给一个简单的例子

也许有,只需要那些EX pressions之一使用?

解决方案

< %%>

<%this.CallMethod()%> - 的基本code座。

&其中;%=%GT;

<%=文本%> - 的嵌入式code语法。同写<%的Response.Write(文本)%>

<%:%>

<%:文字%> - 同上,除了它是一个速记<%= Server.HtmlEn code(文本)%> 。这是在ASP.NET 4 引入,是默认使用的语法。

<%#%>

<%#的eval(的ColumnName)%> - 用于的绑定。

<%$%>

<%$的AppSettings:settingName%> - 的的 有preFIX如的AppSettings 的ConnectionStrings EX pression语法资源然后后跟实际EX pression。它可以作为一个速记访问资源内联。你甚至可以创建你自己的语法这里使用(感谢@Thomas Levesque的)。此外查看MSDN 了解更多信息。

<%@%>

<%@页面语言=C#%> - 的的指令语法的页/控制设置非常有用。

<% - - %>

<% - 这是一个注释 - %> - 服务器端注释语法。这不同于HTML <! - 评论 - > 语法,它的不会的在输出渲染

Can you briefly list the differences between <%= %>, <%# %> and <%$ %> by giving a simple example?

随机对照试验 不同饮食习惯对健康人群肠道菌群 代谢产物和炎症的影响

Maybe one that requires only one of those expressions to be used?

解决方案

<% %>

<% this.CallMethod() %> - Basic code block that executes the statements inside.

<%= %>

<%= "text" %> - Embedded code syntax. Same as writing <% Response.Write("text") %>.

<%: %>

<%: "text" %> - Same as above except it's a shorthand for <%= Server.HtmlEncode("text") %>. This was introduced in ASP.NET 4 and is the default syntax used.

<%# %>

<%# Eval("ColumnName") %> - Used for databinding.

<%$ %>

<%$ AppSettings: settingName %> - The expression syntax has a prefix such as AppSettings, ConnectionStrings, or Resources and then a : followed by the actual expression. It can be used as a shorthand to access resources inline. You can even create your own syntax used here (Thanks @Thomas Levesque). Also see MSDN for more info.

<%@ %>

<%@ Page language="C#" %> - The directive syntax useful for page/control settings.

<%-- --%>

<%-- This is a comment --%> - Server-side comment syntax. This differs from the HTML <!-- a comment --> syntax in that it won't be rendered in the output.

阅读全文

相关推荐

最新文章