[英]How to disable/cancel selection of elements(text inside) generated by @Html.EditorFor or contents of table
How to cancel/disable selecting text: 如何取消/禁用选择文本:
@Html.EditorFor
由@Html.EditorFor
生成 By disabling selecting text I mean block possibility of marking/selectin/choosing text like on image below: 通过禁用选择文本,我的意思是阻止标记/选择/选择文本的可能性,如下图所示:
<table class="table">
<tr>
<th>
No.
</th>
<th>
@Html.DisplayNameFor(model => model.LastName)
</th>
<th>
@Html.DisplayNameFor(model => model.FirstName)
</th>
<th>
@Html.DisplayNameFor(model => model.CellNumber)
</th>
<th>
@Html.DisplayNameFor(model => model.SecondaryPhoneNumber)
</th>
<th>
@Html.DisplayNameFor(model => model.Address)
</th>
<th></th>
</tr>
@foreach (var item in Model) {
<tr>
<td>
@noPerson @{noPerson++;}
</td>
<td>
@Html.DisplayFor(modelItem => item.LastName)
</td>
<td>
@Html.DisplayFor(modelItem => item.FirstName)
</td>
<td>
@Html.DisplayFor(modelItem => item.CellNumber)
</td>
<td>
@Html.DisplayFor(modelItem => item.SecondaryPhoneNumber)
</td>
<td>
@Html.DisplayFor(modelItem => item.Address)
</td>
<td>
@Html.ActionLink("Details", "Details", new { id = item.Id }, new { @class = "btn btn-info btn-xs" }) |
@Html.ActionLink("Edit", "Edit", new { id = item.Id }, new { @class = "btn btn-warning btn-xs" })
@if (Request.IsAuthenticated && User.IsInRole("Admin")) { <text> |</text>
@Html.ActionLink("Delete", "Delete", new { id = item.Id }, new { @class = "btn btn-danger btn-xs" })
}
</td>
</tr>
}
</table>
From other questions, just add CSS 从其他问题开始,只需添加CSS
body{
-webkit-touch-callout: none;
-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.