View
View('具体的地址')
地址跳转
<text>
<text> 标签是一个Razor 特殊处理的元素。Razor将<text> 块的内部内容视为内容块,
不呈现包含那些内容的<text> 标签(这意味着只呈现<text>内容内容,不呈现标签本身)。
这使呈现没有被HTML元素包装的多行内容块变得方便。
可以实现多行输出
两个连续的@@符号会被渲染为一个@符号
@:文本输出,跟使用text标签一样,单行输出
显示渲染输出
<span> ISBN@(isbnNumber)</span>
当要渲染输出的代码@前无空格或标记位时,我们需要使用小括弧进行显式的渲染输出
渲染输出动态方法
对于动态方法返回值之类的输出我们使用小括弧将代码闭合起来即可
@(MyClass.MyMethod<AType>())
与纯文本混合
方法一:
@if(foo)
{
<text>Plain Text</text>
}
方法二:
@if(foo)
{
@:Plain Text
}
创建Razor委托
创建Razor 委托来复用一些视图逻辑
@{
Func<dynamic,object> b=
@<strong>@item</strong>;
}
@b("Bold this")