Thursday 16 January 2014

JQuery:How to Disable Cut,Copy and Paste of TextBox in ASP.NET

Hi friends,in this article i will explain about JQuery:How to Disable Cut,Copy and Paste in ASP.NET.

Write the below code in the .aspx page
ASP.NET:                                              Previous Article>>Copy and Paste User Selected TextKey
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title>JQuery:How to Disable Cut,Copy and Paste in ASP.NET</title>
    <script type="text/javascript" src="http://ajax.microsoft.com/ajax/jquery/jquery-1.4.4.min.js">
    </script>
    <script type="text/javascript" language="javascript">
        ///First Way
        $(document).ready(function () {
            $('#txtDisable').live("cut copy paste", function (e) {
                e.preventDefault();
            });
        });

        ///Second Way
        $(document).ready(function () {
            $('#txtSecond').bind("cut copy paste", function (e) {
                e.preventDefault();
            });
        });
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <h3>JQuery:How to Disable Cut,Copy and Paste in ASP.NET</h3>
    <span>Disable Cut,Copy and Paste using live() method</span><br />
    <asp:TextBox ID="txtDisable" runat="server"></asp:TextBox><br />
       <span>Disable Cut,Copy and Paste using bind() method</span><br />
    <asp:TextBox ID="txtSecond" runat="server"></asp:TextBox><br />
    <%--  Third Way--%>
    <span>Disable Cut,Copy and Paste using oncopy,oncut and onpaste by giving return false</span><br />
    <asp:TextBox ID="txtThird" runat="server" oncopy="return false;" oncut="return false;"
        onpaste="return false;"></asp:TextBox>
    </form>
</body>
</html>

In above code i show how to disable Cut,Copy and Paste of textbox in 3 ways.
Live Demo:




                    Previous Article>>  Copy and Paste User Selected Text
"If you like my blog or articles, you can appreciate by leaving your comments or Liking my Facebook pageAspdotnet-kishore, following on Google+ Aspdotnet-Kishore, Twitter  on AspdotnetKishore, Linked in Aspdotnet-Kishore, stumbling my posts on stumble upon and subscribing on  RSSfeed Aspdotnet-Kishore for free updates directly to your Email inbox . Watch my blog  for more articles."

No comments:

Post a Comment

© 2012-2018 Aspdotnet-Kishore.blogspot.com. All Rights Reserved.
The content is copyrighted to Kishore and may not be reproduced on other websites without permission from the owner.