ASP.NET <%= %>与<%:%>
看来我错过了一些东西。但自从 .Net 4.0 出现以来,我一直在看到 ASP.NET 的 <%: %>
语法的参考。看起来它与 <%= %>
类似,但显然新语法是有原因的。我尝试过谷歌,但搜索 <%: %>
似乎没有返回任何内容。 <%: %>
语法有什么作用?它是在 .Net 4.0 还是 3.5 中引入的?有人可以启发我吗?
已编辑:请提供参考或示例
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我相信 <%: %>是 auto HtmlEncoding
Scott Gu 的这篇文章将有助于解释 - 它是在 .net 4 和 MVC2 中引入的
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
i believe the <%: %> is auto HtmlEncoding
this post from Scott Gu will help to explain - it was introduced in .net 4 and MVC2
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
:
进行 html 编码。斯科特·格思里(Scott Guthrie)有 一篇不错的文章详细描述了它。
不要在已经编码的地方使用它,否则它会双重编码。不过,如果您想输出 HTML 之类的内容,这会很有用。
:
does html encoding.Scott Guthrie has a nice post describing it in detail.
Don't use this where it is already encoded otherwise it will double encoded it. This is useful if you want to output things like HTML, though.