【发布时间】:2015-10-24 18:12:14
【问题描述】:
由 Visual Studio 搭建的 Razor 视图包含一个“actions”元素,其中的链接由竖线字符分隔 (|)
<td>
@Html.ActionLink("Edit", "Edit", new { id = item.Id }) |
@Html.ActionLink("Details", "Details", new { id = item.Id }) |
@Html.ActionLink("Delete", "Delete", new { id = item.Id })
</td>
我想有条件地呈现这些链接:
<td>
@if (item.IsSuccess)
{
@Html.ActionLink("Edit", "Edit", new { id = item.Id }) |
@Html.ActionLink("Details", "Details", new { id = item.Id }) |
@Html.ActionLink("Delete", "Delete", new { id = item.Id })
}
</td>
上面的代码在 Visual Studio 中似乎是正确的,但是执行会导致 Compilation Error
Compilation Error Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately. Compiler Error Message: CS1513: Expected sign }. Source Error: Line 491: } Line 492: } Line 493:}
你能指出问题出在哪里吗?代码看起来语法正确。
【问题讨论】:
标签: c# .net asp.net-mvc razor asp.net-mvc-5