How to disable copy paste in asp.net

{0 Comments}

Most of clients want to disable copy and paste system in their project, to save their valuable text then we have to stop most of the function of browser like copy, paste, and right-click and view source option. There is need of very strong script to provide at least this type of security. So the following JavaScript will full fill your this requirement.

 Javascript |  copy code |? 
01
 <script language="javascript"> 
02
function click() { 
03
return false;} 
04
function click1(){if (event.button==2) {return false; }} 
05
function CtrlKeyDown(){ 
06
if (event.keyCode==67&&event.ctrlKey) 
07
{ 
08
  clipboardData.setData('text',''); 
09
  return false;  
10
} 
11
} 
12
document.onkeydown=CtrlKeyDown; 
13
document.onselectstart=click; 
14
document.onmousedown=click1; 
15
    </script>
16
 
17
    <noscript>
18
        <iframe src="*.html"></iframe>
19
    </noscript>
20
 
21
    <script language="javascript">  
22
<!--  
23
if (window.Event)  
24
document.captureEvents(Event.MOUSEUP);  
25
function nocontextmenu(){  
26
event.cancelBubble = true  
27
event.returnValue = false;  
28
return false;  
29
}  
30
function norightclick(e){  
31
if (window.Event){ 
32
if (e.which == 2 || e.which == 3) 
33
return false; 
34
}  
35
else if (event.button == 2 || event.button == 3) 
36
{ 
37
event.cancelBubble = true; 
38
event.returnValue = false;return false;}  
39
}  
40
document.oncontextmenu = nocontextmenu; // for IE5+  
41
document.onmousedown = norightclick; // for all others  
42
//--></script>

Leave a Comment

Your email address will not be published.