Is there a way to disable copying data from a table in my view? I have a razor page which has a table and I populate it with data but I am trying to disable the option for user to copy the data.
@page "/products"
@attribute [Authorize]
@inject NavigationManager NavigationManager
@inject IViewProductsByNameUseCase ViewProductsByNameUseCase
<h3>Product List</h3>
<br/>
<ViewProductsComponent OnSearchProducts="OnSearchProducts"></ViewProductsComponent>
@if (listProducts != null)
{
<table >
<thead>
<tr>
<th>Name</th>
<th>Home place</th>
<th>Expiration</th>
<th>Phone number</th>
<th>Tea</th>
<th>Local</th>
<th>App</th>
<th>Company /Lease</th>
<th>Road time</th>
<th>Notes</th>
<th></th>
</tr>
</thead>
<tbody>
@foreach(var product in this.listProducts)
{
<ProductItemComponent
Product="product"
OnProductDeleted="OnProductDeleted"></ProductItemComponent>
}
</tbody>
</table>
}
<br/>
<button type="button" @onclick="AddProduct">Add Product</button>
I selected the product and I can easily copy it. Can copying be somehow disabled?
CodePudding user response:
Is there a way to disable copying data from a table in my view?
No.
You cannot DRM HTML.
You cannot control how web-browsers display or interact with HTML.
Otherwise, how else could AdBlockers work?
CodePudding user response:
You can't completely prevent it. But you can make copying a little more difficult. For this, you can use JavaScript code that prevents using right-click, double-click, and keyboard shortcuts.