C-Sharpcorner - Latest Articles: How to Disable the Cut, Copy and Paste in the Whole Asp.Ne...

来源:互联网 时间:1970-01-01

In the real world, sometimes developer needs to restrict the basic facility like cut, copy and paste on a whole web page not on a particular control. At that time you will need some easy way to stop these kinds of facilities on the page not the disabling these facilities in each control.

Suppose you have 20 ‘TextBox’ controls in your page and you want to restrict the cut, copy and paste in all textboxes, then you not need to write the disable code in each textbox. In this scenario, you have to just write the disable code only in ‘body’ tag.

To explain such implementation, I will follow some steps;

Step 1:Create a Asp.Net Empty Website named ‘My Project’.

Step 2:Add a new web form named ‘Default.aspx’ into it.

Step 3:Add 2 ‘TextBox’ controls in the page named ‘Default.aspx’ .

Step 4:

  1. On Cut: By this, you can disable the ‘Cut ‘ facility in both ‘TextBox’ Control.

    Syntax: oncut= “return false”;

  2. On Copy: By this, you can disable the ‘Copy ‘ facility in both ‘TextBox’ Controls.

    Syntax: oncopy= “return false”;

  3. On Paste: By this, you can disable the ‘Cut‘ facility in both ‘TextBox’ Controls. Syntax: onpaste= “return false”;
    To disable the All (Cut, Copy and Paste) in whole page:

Conclusion

In this article, I have described that how you can restrict the user to use cut, copy and paste facility in whole page and I hope it will be beneficial for you.


相关阅读:
Top