Related Posts Plugin for WordPress, Blogger...

About

Follow Us

Monday 16 March 2015

Introduction:

Some time we don’t want to allow paste or drag text to textbox. So that user has to type the test in textbox. This can be done by using jQuery.

In this article today I will explain how we can disable copy, cut, paste and drag-drop options in asp.net text box using Jquery

Source Code:

Create a web form and add following script in head tag.
<script type="text/javascript"src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
   <script type="text/javascript">
       $(function () {
           $('.disable').bind('cut copy paste drop', function (e) {
               e.preventDefault();
               alert('Cut,Copy,Drop and Paste options are disabled');
           });
       });
</script>

Design page as given below:

<fieldset style="width:400px;height:auto;align:center;">
    <legend>Disable Copy-Paste and Drag-Drop</legend>
    <table>
    <tr><td>Address</td><td><asp:TextBox ID="txtaddress"CssClass="disable" TextMode="MultiLine" runat="server"></asp:TextBox></td></tr>
    <tr><td></td><td>Dummy Text</td></tr>
    </table>

    </fieldset>

0 comments:

Post a Comment