【发布时间】:2017-05-30 07:14:56
【问题描述】:
<tbody>
@foreach (var item in Model.Roles)
{
<tr>
<td>
@Html.DisplayFor(modelItem => item.Name)
</td>
<td>
@foreach (var permission in item.Permissions)
{
@Html.DisplayFor(modelItem => permission)
<br/>
}
</td>
<td>
@Html.ActionLink("Edit", "EditRole", > "Roles", new { RoleID = item.RoleID}, null) // i want when RoleID = 1, it will > hide the button
@{ if (item.RoleID == 1) // this is the condition
{
@:style = "display:none"
}
}
</td>
</tr>
}
</tbody>
【问题讨论】:
-
下次请尝试更好地格式化您的代码。另外,为什么不简单地将
Html.ActionLink()放在您的 if 语句中? -
你可以像这样给 ActionLink 一些 ID - 并在你的条件下使用 JQ 隐藏
标签: c# visual-studio razor