Dissable Copy and Paste TextBox Text In ASP.NET Without JavaScript

In this article i will explain how to dissable the copy & paste feature of a textbox without JavaScript code


Sometimes there is a need to disable the copy & paste feature from the ASP.Net text box. This article provides the details of how to disable the copy & paste feature in a TextBox. However you can use it for div, paragraph tag, form tag and so on which are also applicable.
Let us create an application to do this, as:
  1. "Start" - "All Programs" - "Microsoft Visual Studio 2010".
  2. "File" - "New web Site" - "C#" - "Empty WebSite" (to avoid adding a master page).
  3. Provide the web site a name such as dissableCopyPaste or another as you wish and specify the location.
  4. Then right-click on Solution Explorer - "Add New Item" - "Default.aspx" page.
  5. Drag and drop one textbox onto the <form> section of the Default aspx page.
Disable Copy and Paste in an ASP.NET Webpage TextBox without JavaScript; we need to set the following properties of the TextBox:
  • oncopy="return false"
  • onpaste="return false"
  • oncut="return false"
Now the source code of the Default.aspx should look as in the following:

@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs"  Inherits="_Default" %>

 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head id="Head1" runat="server">




    <form id="form1" runat="server">

    <%--added by vithal wadje--%>


        <asp:TextBox ID="TextBox1" runat="server" oncopy="return false" onpaste="return false"

            oncut="return false" TextMode="MultiLine">






Now run the application that looks as in the following:


Now copy the above data and past it outside in Notepad or any other tool it can not be copied with. Similarly,
 copy the Notepad or any other data into the above Texbox; it cannot be copied.


I hope this article is useful for all readers if you have any suggestion then please contact me.