<%$,<%@<%=,<%#......这是怎么回事? [英] <%$, <%@, <%=, <%# ... what's the deal?

查看:171
本文介绍了<%$,<%@<%=,<%#......这是怎么回事?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在编程经典的ASP和ASP.NET中,我看到的标记为服务器端code内不同的标签。

I've programmed in both classic ASP and ASP.NET, and I see different tags inside of the markup for server side code.

我最近遇到一个<一个href=\"http://blogs.msdn.com/dancre/archive/2007/02/13/the-difference-between-lt-and-lt-in-asp-net.aspx\">good在MSDN博客之间即越过的区别:

I've recently come across a good blog on MSDN that goes over the difference between:


  • &LT;%= (百分比与equals一起签署)和

  • &LT;%#(百分号和哈希/英镑/井号)

  • <%= (percentage together with equals sign) and
  • <%# (percent sign and hash/pound/octothorpe)

&LT;%#仅在数据绑定评估,&LT;%= 在渲染计算) ,但我也看到:

(<%# is evaluated only at databind, and <%= is evaluated at render), but I also see:


  • &LT;%$ (百分比和美元符号)和

  • &LT;%@ (百分号和符号)

  • <%$ (percent and dollar sign) and
  • <%@ (percent sign and at symbol).

我相信&LT;%@ 负荷之类的组件,也许&LT;从配置文件%$ 负载的东西?我不太肯定。

I believe <%@ loads things like assemblies and perhaps <%$ loads things from config files? I'm not too sure.

我只是想知道如果任何人都可以澄清这一切对我来说,可能解释为什么创建貌似有一个类似的目的,这么多不同的标签是非常重要的?

I was just wondering if anyone could clarify all of this for me and possibly explain why it's important to create so many different tags that seemingly have a similar purpose?

推荐答案


  • &LT;%%GT; - 是的在线code (尤其是逻辑流程)

  • &LT;%$%&GT; - 是的评估前pressions (如资源变量)

  • &LT;%@%GT; - 是的页面指令的,注册组件,导入命名空间,等等。

  • &LT;%=%&GT; - 是短手的Response.Write (讨论的这里

  • &LT;%#%&GT; - 用于数据结合前pressions 的。

  • &LT;%:%GT; - 是短手<一个href=\"http://weblogs.asp.net/scottgu/archive/2010/04/06/new-lt-gt-syntax-for-html-encoding-output-in-asp-net-4-and-asp-net-mvc-2.aspx\">Response.Write(Server.HTMLEn$c$c()) ASP.net 4.0 +

  • &LT;%#:%GT; - 用于数据绑定前pressions 并自动为HTMLEn codeD。

  • &LT;% - - %GT; - 是的服务器端的评论

  • <% %> - is for inline code (especially logic flow)
  • <%$ %> - is for evaluating expressions (like resource variables)
  • <%@ %> - is for Page directives, registering assemblies, importing namespaces, etc.
  • <%= %> - is short-hand for Response.Write (discussed here)
  • <%# %> - is used for data binding expressions.
  • <%: %> - is short-hand for Response.Write(Server.HTMLEncode()) ASP.net 4.0+
  • <%#: %> - is used for data binding expressions and is automatically HTMLEncoded.
  • <%-- --%> - is for server-side comments
  • 这篇关于&LT;%$,&LT;%@&LT;%=,&LT;%#......这是怎么回事?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆