请告诉我这个语法在Visual Studio中的意义 [英] Whats the meaning of this syntax in Visual studio
问题描述
有谁知道下面的4 code snipets的意义(或快捷方式,我不知道该怎么称呼他们)在Visual Studio:
Does anyone know the meaning of the following 4 code snipets (or shortcuts, i don't know how to call them) in Visual Studio:
<%= variable %>
<%# variable %>
<%: variable %>
<%$ variable %>
我认识的第一个插入一个值到页面,第二个是用于数据绑定。
I know the first one inserts a value into the page and the second one is used for data binding.
还有没有其他类似的快捷方式?
Are there any other similar shortcuts?
推荐答案
第一个,&LT;%=%&GT;
被称为一个内联前pression或code渲染块。 ( http://msdn.microsoft.com/en -us /库/ k6xeyd4z(v = VS.100)的.aspx )
The first one, <%= %>
is called an inline expression, or a code render block. (http://msdn.microsoft.com/en-us/library/k6xeyd4z(v=vs.100).aspx)
第二个,&LT;
被称为数据绑定前pression;%#%&GT。 ( http://msdn.microsoft.com/en -us /库/ bda9bbfx(v = VS.100)的.aspx )
The second one, <%# %>
is called a data binding expression. (http://msdn.microsoft.com/en-us/library/bda9bbfx(v=vs.100).aspx)
第三个,&LT;%:%GT;
提供了一种自动HTML EN code中的code的输出。我不知道什么是它叫,但这样找不到你就可以了文档页面,但是没有对斯科特Guthrie的博客的一篇文章:<一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\" rel=\"nofollow\">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
The third one, <%: %>
provides a way to automatically HTML encode the output of the code. I'm not sure what's it's called though so can't find you a documentation page on it, however there is a post on Scott Guthrie's blog: 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
第四个,&LT;%$%&GT;
被称为前pression建设者语法。 ( http://msdn.microsoft.com/en -us /库/ d5bd1tad(v = VS.100)的.aspx )
The fourth one, <%$ %>
is called expression builder syntax. (http://msdn.microsoft.com/en-us/library/d5bd1tad(v=vs.100).aspx)
这篇关于请告诉我这个语法在Visual Studio中的意义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!