1

@if (Model.CanMaintainNcrLineManagement) {
<tr>
  <td>@Html.TextAreaFor(model => model.Description, new { id = "txArNcrLineDescriptionValue", @style = "height:520px" })</td>
</tr>
} else {
<tr class="read-only-editor">
  <td>@Html.TextAreaFor(model => model.Description, new { id = "txArNcrLineDescriptionReadOnly", @style = "height:520px" })</td>
</tr>
}

I want to disable the copy-past option from the text editor box. I have used below both codes to disable it but its not working. Please give me some solution

$('body').bind('copy paste', function(e) {
  e.preventDefault();
  return false;
});
<body oncopy="return false" oncut="return false" onpaste="return false">
Scath
  • 3,777
  • 10
  • 29
  • 40
MVS
  • 21
  • 7

2 Answers2

0

Change your code and your text editor must be inside body tag and will prevent all inside body tag.

<body oncopy="return false" oncut="return false" onpaste="return false">

To

<body onselectstart="return false" onpaste="return false;" onCopy="return false" onCut="return false" onDrag="return false" onDrop="return false"> 
Sudhir Ojha
  • 3,247
  • 3
  • 14
  • 24
0

I tested this in Chrome 66.0.3359.181, I.E. 11, and FireFox 59.0.3 and it is disabling copying and pasting into anything in the body or the input.

 $('body').bind('copy paste', function (e) {
        e.preventDefault(); return false;
    });
<body oncopy="return false" oncut="return false" onpaste="return false">
Scath
  • 3,777
  • 10
  • 29
  • 40
  • Yes Thanks for reply,, Ya its working for me now i used text ID and used this code inside Script Body where i called – MVS May 24 '18 at 06:24
  • If this helped answer your question please accept it as answered instead of commenting. – Scath May 25 '18 at 13:47