我有一张包含很多td的表格。当我点击打印按钮时,我想在浏览器中隐藏其中一个打印页面。怎么做? 这是索引页面代码:
<div id="div_print"><table class="table table-bordered">
<tr class="info">
<th dir="rtl">
@Html.DisplayNameFor(model => model.a)
</th>
<th dir="rtl">
@Html.DisplayNameFor(model => model.b)
</th>
<th dir="rtl">
@Html.DisplayNameFor(model => model.c)
</th>
</tr>
</div>
@foreach (var item in Model) {
<tr>
<td>
@{
ViewData["class"]= "text-uppercase";
}
@Html.DisplayFor(modelItem => item.a)
</td>
<td>
@Html.DisplayFor(modelItem => item.b)
</td>
<td>
@Html.DisplayFor(modelItem => item.c)
</td>
<td>
@Html.ActionLink("Edit", "Edit", new { id=item.z}, new { @class = "btn btn-primary" }) |
@Html.ActionLink("Details", "Details", new { id=item.z}, new { @class = "btn btn-primary" }) |
@Html.ActionLink("Delete", "Delete", new { id=item.z}, new { @class = "btn btn-warning" })
</td>
</tr>
}
</table>
我想隐藏这一部分:
<td>
@Html.ActionLink("Edit", "Edit", new { id=item.z}, new { @class = "btn btn-primary" }) |
@Html.ActionLink("Details", "Details", new { id=item.z}, new { @class = "btn btn-primary" }) |
@Html.ActionLink("Delete", "Delete", new { id=item.z}, new { @class = "btn btn-warning" })
</td>
答案 0 :(得分:0)
使用CSS执行此操作:
@media print
{
.not-printable, .not-printable *
{
display: none !important;
}
}
然后将not-printable
添加到您不想打印的元素:
<div class="not-printable"></div>