Nếu bạn muốn hiển thị hình ảnh đa bạn có thể sử dụng bất động sản trong Html.ActionLink
View
của bạn như hình dưới đây. Trong ví dụ này, tôi sử dụng Detail/Edit/Delete images dưới dạng nút Action.
Lưu ý: Loại Title
, Controller
và Action
tên trong Html.ActionLink
theo dự án của bạn. Nếu bạn muốn sử dụng tiêu đề trống, chỉ cần nhập "" cho chúng.
....
//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>
Ví dụ đầy đủ, bạn có thể nhìn vào đây: How to use WebGrid in a cshtml view?
trọng.
Nguồn
2013-11-03 10:18:17
Tôi rất muốn đề xuất sử dụng Url.Action() –