Hello All, We are going to start new batch from next week. message/call or mail us for more details.

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


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

3 comments:

  1. Thanks for your informative blog!!! Your article helped me to understand the future of .net programming language. Keep on updating your with such awesome information. DOT NET Training in Chennai | dot net course Chennai

    ReplyDelete
  2. Thanks for sharing these information. It’s a very nice topic. We are providing online training classes dotnet-online-training

    ReplyDelete