Disable copy, paste, cut with jQuery in ASP.NET

Just follow the steps below:

1. Put : 

<script type="text/javascript">

2. Inside block script put $(document).ready(function() function

<script type="text/javascript">

$(document).ready(function() {

3. Can bind for cut , copy , paste for event handler to target textbox 

<script type="text/javascript">

$(document).ready(function() {

$('#<%=txtTarget.ClientID%>').bind('cut copy paste', // ClinetID properties : Gets the control ID for HTML markup that is generated by ASP.NET

4. Prevent behavior that include "copy, cut, paste " for this textbox

<script type="text/javascript">

$(document).ready(function() {

$('#<%=txtTarget.ClientID%>').bind('cut copy paste',

function(e) { e.preventDefault(); // default behavior disable

5. Showing alert that cut , copy , pastecut , copy , paste is disabled!

<script type="text/javascript">

$(document).ready(function() {

$('#<%=txtTarget.ClientID%>').bind('cut copy paste',

function(e) { e.preventDefault();

alert("cut , copy , paste disable !!!!!");

});

});

</script>


picsample.jpg


 

 


1 - put : 

<script type="text/javascript">

2 - inside block script put $(document).ready(function() function

<script type="text/javascript">

$(document).ready(function() {

3 - can bind for cut , copy , paste for event handler to target textbox 

<script type="text/javascript">

$(document).ready(function() {

$('#<%=txtTarget.ClientID%>').bind('cut copy paste', // ClinetID properties : Gets the control ID for HTML markup that is generated by ASP.NET

4 - prevent behavior that include " copy , cut , paste " for this is textbox

<script type="text/javascript">

$(document).ready(function() {

$('#<%=txtTarget.ClientID%>').bind('cut copy paste',

function(e) { e.preventDefault(); // default behavior disable

5 - show alert based on cut , copy , paste disable!

<script type="text/javascript">

$(document).ready(function() {

$('#<%=txtTarget.ClientID%>').bind('cut copy paste',

function(e) { e.preventDefault();

alert("cut , copy , paste disable !!!!!");

});

});

</script>

 

The End

picsample.jpg