在ASP.NET MVC%=;和&lt:%之间;&LT有什么区别? [英] What is the difference between <%: and <%= in ASP.NET MVC?

查看:91
本文介绍了在ASP.NET MVC%=;和&lt:%之间;&LT有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我找不到该信息的任何地方。大概是因为谷歌被忽略的关键字。是否有使用之间的差异<%:<%= 在你的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; 是<一个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"相对=nofollow>在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).

这篇关于在ASP.NET MVC%=;和&lt:%之间;&LT有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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