&是什么LT;%:%GT;在ASP.NET(MVC2)呢? [英] What does <%: %> do in ASP.NET (MVC2)?

查看:97
本文介绍了&是什么LT;%:%GT;在ASP.NET(MVC2)呢?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

一个同事最近在变更检查,其中许多形式和LT上的前pressions的;(%)=(...)%>被更改为<%:(......)%>

A coworker recently checked in a changeset where lots of expressions on the form <%= (...) %> were changed to <%: (...) %>.

我在聆听℃的模糊的记忆;%:的确,但不记得了。这太深夜打电话给我的同事,而谷歌和Bing都似乎无法搜索字符串&LT;%:

I have a vague recollection of having heard what <%: does, but cannot remember. It's too late in the night to call my coworker, and Google and Bing both seem unable to search for the string "<%:".

有人可以告诉我,好吗?

Can someone enlighten me, please?

推荐答案

据HtmlEn codeS字符串,如果它已不是EN codeD。

It HtmlEncodes the string, if it hasn't already been encoded.

在已不是EN codeD部分就是MvcHtmlString进行了介绍。 MVC2回报许多的HtmlHelper方法MvcHtmlString重新不应重新连接codeD present字符串。
在&lt;%:%>明白不要再带code

The "hasn't already been encoded part" is why MvcHtmlString was introduced. MVC2 returns MvcHtmlString from many HtmlHelper methods to represent strings that should not be re-encoded. The <%: %> knows not to re-encode.

请参阅http://stackoverflow.com/questions/2293357/what-is-an-mvchtmlstring-and-when-should-i-use-it一个良好的讨论。

See http://stackoverflow.com/questions/2293357/what-is-an-mvchtmlstring-and-when-should-i-use-it for a good discussion.

这篇关于&是什么LT;%:%GT;在ASP.NET(MVC2)呢?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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