我正在使用ASP.NET MVC 5和Entity Framework。
目前我的桌子上有按钮:
<table class="table">
<tr>
<th>
@Html.ActionLink("Name", "DisplayAllAdmin", new { sortOrder = ViewBag.NameSortParm }, htmlAttributes: new { @class = "sortLabel" })
</th>
<th>
@Html.DisplayNameFor(model => model.Description)
</th>
</tr>
@foreach (var item in Model) {
<tr>
<td>
@Html.DisplayFor(modelItem => item.Name)
</td>
<td>
@Html.DisplayFor(modelItem => item.Description)
</td>
<td>
<a href="@Url.Action("Download", "Sth", new { id = item.Id }, null)"><i class="material-icons">get_app</i></a>
<a href="@Url.Action("Delete", "Sth", new { id = item.Id }, null)"><i class="material-icons">delete</i></a>
</td>
</tr>
如何添加下一个按钮以显示记录详细信息?
现在我有这样的想法:
<tr style="display:none">
<td>@Html.DisplayFor(modelItem => item.TbVersion)</td>
</tr>
<script type="text/javascript" language="javascript">
function DisplayDetails(id)
{
if (document.getElementById("detailsField").style.display == "none")
{
document.getElementById("detailsField").style.display = "block";
}
else
{
document.getElementById("detailsField").style.display = "none"
}
}
</script>
<button onclick="DisplayDetails(id)"><i class="material-icons">info</i></button>
但我在传递身份证方面遇到了麻烦。有什么建议?非常感谢。
答案 0 :(得分:0)
尝试像这样设置参数
<a href="@Url.Action('Delete', 'Sth', new { id = " + item.Id + "}, null)"><i class="material-icons">delete</i></a>