ASP.NET MVC:在C#code座使用@ [英] ASP.NET MVC: use of @ in C# code block

查看:146
本文介绍了ASP.NET MVC:在C#code座使用@的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是有点困惑与使用@。在下面的code我第一次写 Html.ActionLink(...),而不是 @ Html.ActionLink(...),因为我是在一个如果块(C#code)。所以,我想确切地了解什么时候我必须使用@当我不都使用它。

I'm a little bit confused with the use of @. In the following code I first wrote Html.ActionLink(...) instead of @Html.ActionLink(...) because I was in a if block (C# code). So, I would like to understand exactly when I do have to use @ and when I don´t have to use it.

<td width="32%" align="center">
     @if (Model.SeccionImpresos != null)
     {
           @Html.ActionLink("IMPRESOS", "Index", "Trabajo", null, null, "#impresos", new { id = Model.Id }, null);
     }
</td>

我AP preaciate有这方面的帮助。

I appreaciate any help on this.

推荐答案

@ 有两种用途:

  • 它用于启动code的的( @if @foreach ,@ {...}等))

  • It's used to start a code block (@if, @foreach, @{ ... }, etc) from a markup context (as opposed to from another code block)

它用于code的掘金的&ndash的;这是写入到输出流EX pressions( @ EX pression )。

It's used for code nuggets – expressions which are written to the output stream (@expression).

Html.ActionLink 没有 @ 在code块创建正常的方法调用放弃其的结果。

Writing Html.ActionLink without @ in a code block creates a normal method call that discards its result.

这篇关于ASP.NET MVC:在C#code座使用@的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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