ASP.NET <%= %>与<%:%>

发布于 2024-09-28 07:26:05 字数 288 浏览 1 评论 0 原文

看来我错过了一些东西。但自从 .Net 4.0 出现以来,我一直在看到 ASP.NET 的 <%: %> 语法的参考。看起来它与 <%= %> 类似,但显然新语法是有原因的。我尝试过谷歌,但搜索 <%: %> 似乎没有返回任何内容。 <%: %> 语法有什么作用?它是在 .Net 4.0 还是 3.5 中引入的?有人可以启发我吗?

已编辑:请提供参考或示例

It seems I am missing something. But ever since .Net 4.0 came out I have been seeing reference to <%: %> syntax for ASP.NET. It seems like it is similar to <%= %> but clearly there is a reason for the new syntax. I tried google but searching <%: %> doesn't seem to return anything. What does the <%: %> syntax do? Was it introduced in .Net 4.0 or 3.5? Can someone enlighten me?

Edited: Please provide reference or examples

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

古镇旧梦 2024-10-05 07:26:05

我相信 <%: %>是 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

别挽留 2024-10-05 07:26:05

: 进行 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文