Click here to Skip to main content
15,905,144 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi

any one please tell me how to disable the copy and paste for a text box for my web page with c# code
Posted
Updated 6-Dec-16 2:49am

This Code may Solve ur problem

ASP.NET
<asp:TextBox ID="TextBox1" runat="server"
         oncopy="return false"
         onpaste="return false"
         oncut="return false">
</asp:TextBox>
 
Share this answer
 
v2
Comments
patil.ravi035 21-Dec-11 23:59pm    
thanks for the answer
D Anil Kumar 22-Dec-11 4:13am    
im asking with C# not with javascript.
Dave Kreskowiak 6-Dec-16 9:04am    
There is no C# code for this in an ASP.NET app. The C# code runs ENTIRELY server-side, not client. Your C# code will never know the user hit Paste on a TextBox.

The only thing C# can do is add the "onpaste" event handler to the control if your code is dynamically generating the textbox. This is an uncommon occurance.
 
Share this answer
 
Comments
D Anil Kumar 22-Dec-11 4:13am    
im asking with C# not with javascript.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900