什么是" @"在ASP MVC意味着/吗? [英] What does the "@" in ASP MVC mean/do?
问题描述
我知道这是一个简单的问题,但我是新来的ASP MVC,只是无法找到这个问题的答案在任何地方 - 什么是@,我看到的到处都是?例如:
@ {
ViewBag.Title =欢迎;
}< H2>欢迎及LT; / H>< UL>
@for(INT I = 0; I< ViewBag.NumTimes;我++){
<立GT; @ ViewBag.Message< /李>
}
< / UL>
解决方案
@是剃刀引擎的语法元素,即在ASP.NET MVC 3中使用
您code将显示从
ViewBag.Message
ViewBag.NumTimes
倍文本。ViewBag性质是动态的,并且可以从控制器进行填充。
看看 http://haacked.com /archive/2011/01/06/razor-syntax-quick-reference.aspx 的剃刀语法
I know this is a simple question, but I am new to ASP MVC and just can't find the answer to this anywhere - what is the "@" that I am seeing everywhere? example:
@{
ViewBag.Title = "Welcome";
}
<h2>Welcome</h2>
<ul>
@for (int i=0; i < ViewBag.NumTimes; i++) {
<li>@ViewBag.Message</li>
}
</ul>
@ is a syntax element of Razor engine, that is used in ASP.NET MVC 3.
Your code will show text from ViewBag.Message
ViewBag.NumTimes
times.
ViewBag properties are dynamic and can be populated from controller.
Take a look http://haacked.com/archive/2011/01/06/razor-syntax-quick-reference.aspx to the Razor syntax
这篇关于什么是&QUOT; @&QUOT;在ASP MVC意味着/吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!