在ASP.NET MVC%=;和&lt:%之间;&LT有什么区别?有什么区别、NET、ASP、MVC

2023-09-04 01:10:59 作者:败给自己

我找不到该信息的任何地方。大概是因为谷歌被忽略的关键字。是否有使用之间的差异<%:<%= 在你的aspx页面?他们似乎可以互换的。

I can't find this info anywhere. Probably because Google is ignoring the keywords. Is there a difference between using <%: and <%= in your aspx page? They seem interchangeable.

推荐答案

&LT;%:%&GT; 是在ASP.NET MVC 2 一个新事物。这是一样的&LT;%= Html.En code(文本)%&GT; 。建议始终使用&LT;%:%&GT; 除非你有特殊理由不这样做(例如,您是从一些文件或数据库中呈现的数据是已经连接codeD)。

<%: %> is a new thing in ASP.NET MVC 2. It is the same as <%= Html.Encode("Text") %>. It is recommended to always use <%: %> unless you have some specific reason to not do so (for example, you are rendering data from some file or database that's already been encoded).