Home > ASP.Net, Jquery > JQuery to disable Copy, Paste, Cut and Drop

JQuery to disable Copy, Paste, Cut and Drop


Hi all,

try this example to use JQuery to disable Cut, Copy, Paste and Drop options


<%@ 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>
 <title></title>
 <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
 <script type="text/javascript">
 $(function () {
 var controls = $(".disable");
 controls.bind("paste", function () {
 return false;
 });
 controls.bind("drop", function () {
 return false;
 });
 controls.bind("cut", function () {
 return false;
 });
 controls.bind("copy", function () {
 return false;
 });
 });
 </script>
</head>
<body>
 <form id="form1" runat="server">
 ASP.Net<br />
 <br />
 <asp:TextBox ID="TextBox2" runat="server" CssClass="disable"></asp:TextBox><br />
 <br />
 <asp:TextBox ID="TextBox1" runat="server" TextMode="MultiLine" CssClass="disable"></asp:TextBox><br />
 <br />
 <br />
 </form>
</body>
</html>

Hope this helps

Good Luck.

Categories: ASP.Net, Jquery
  1. No comments yet.
  1. No trackbacks yet.

Leave a comment