如果要显示多张图像,可以使用如下所示Html.ActionLink
的属性。View
在此示例中,我使用详细/编辑/删除图像作为操作列下的按钮。
注意:键入Title
,Controller
并根据您的项目Action
命名。Html.ActionLink
如果您想使用空标题,只需为它们键入“”。
....
//for using multiple Html.ActionLink in a column using Webgrid
grid.Column("Action", format: (item) =>
new HtmlString(
Html.ActionLink("Show Details", "Edit", "Admin", new
{
applicantId = item.ApplicantID,
title = "Detail",
@class = "icon-link",
style = "background-image: url('../../Content/icons/detail.png')"
}, null).ToString() +
Html.ActionLink("Edit Record", "Edit", "Admin", new
{
applicantId = item.ApplicantID,
title = "Edit",
@class = "icon-link",
style = "background-image: url('../../Content/icons/edit.png')"
}, null).ToString() +
Html.ActionLink("Delete Record", "Edit", "Admin", new
{
applicantId = item.ApplicantID,
title = "Delete",
@class = "icon-link",
style = "background-image: url('../../Content/icons/delete.png')"
}, null).ToString()
)
)
....
<style type="text/css">
a.icon-link {
background-color: transparent;
background-repeat: no-repeat;
background-position: 0px 0px;
border: none;
cursor: pointer;
width: 16px;
height: 16px;
margin-right: 8px;
vertical-align: middle;
}
</style>
对于完整的示例,您可能会在这里查看:如何在 cshtml 视图中使用 WebGrid?
问候。