我想创建一组Actionlink并对其进行控制。像
添加|编辑|删除
我试过它
grid.Column(header: "Payload Actions", format: @<text> @if (item.Status == "ERROR") { @Html.ActionLink("Add", "Add", "THRecovery", new {item.id}, new {@class = "addAction", @style = "color:blue;"}) | @Html.ActionLink("Detail", "Detail", "THRecovery", new {item.id}, new {@class = "detailAction", @style = "color:blue;"}) | @Html.ActionLink("Delete", "Delete", "THRecovery", new { item.id }, new { @class = "deleteAction", @style = "color:blue;" }) } @if (item.Status != "ERROR") { @Html.ActionLink("Details", "Details", "THRecovery", new {item.id}, new {@class = "detailAction", @style = "color:blue;"}) } </text> )
我添加了“|”在ActionLink的最后但是它给了我错误 - 意外的令牌。
如果status = ERROR,那么我想显示为Add |细节|删除 如果不是那么只有细节
请建议我如何做到这一点。
答案 0 :(得分:1)
如果你把&#39; |&#39;在<text>
标记内。
像这样:
<text>|</text>
使用您的代码:
@Html.ActionLink("Add", "Add", "THRecovery", new {item.id}, new {@class = "addAction", @style = "color:blue;"}) <text>|</text>
您也可以使用@:|
。这样管道字符将被读作服务器代码,并将打印&#39; |&#39;角色没有任何问题。