.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Code Snippets >> ASP.NET Controls >> Post New Resource Bookmark and Share   

 Subscribe to Code Snippets

Disable or restrict user from cut, copy paste in TextBox without Javascript or JQuery

Posted By:Amit Mehra       Posted Date: January 22, 2013    Points: 40    Category: ASP.NET Controls    URL: http://www.dotnetspark.com  

You can Disable or restrict user from cut, copy paste in a TextBox or TextArea in asp.net without using Javascript or JQuery by setting properties of the TextBox.
 

You can Disable or restrict user from cut, copy paste from TextBox or TextArea in asp.net without using Javascript or JQuery by setting properties of the TextBox.

All you have to do is set the following property of TextBox or TextArea of asp.net control or TextBox or TextArea of HTML control. Because IN ASP.NET MVC HTML control is being used.

oncopy = return false // To disable copy functionality
onpaste = return false // To disable paster functionality
oncut = return false // To disable cut functionality

now lets see the html code for the same

For asp.NET TextBox control

<asp:TextBox runat="server" oncopy="return false" onpaste="return false" oncut="return false"/>

For HTML TextBox control (type=text)

<input type="text" name="name" value=" " oncopy="return false" onpaste="return false" oncut="return false"/>

Happy coding


     

Further Readings:

Responses

No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More code samples in C#, ASP.Net, Vb.Net and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend