When using jQuery, it is quite simple and fully compatible with ASP.NET:
<script type='text/javascript' src='http://jqueryjs.googlecode.com/files/jquery-1.3.2.min.js'> </script> <script type="text/javascript"> $(function() { $('input[id$=TextBox2]').bind('cut copy paste', function(e) { e.preventDefault(); alert('You cannot ' + e.type + ' text!'); }); }); </script>
Here is an article explaining how this works with ASP.NET:
http://www.dotnetcurry.com/ShowArticle.aspx?ID=398
As Scott pointed out: during production, you should put a jQuery link on the bottom of your html (still inside the body tag).
UPDATE
Since you asked to completely exclude the context menu, you can do something like this:
Add this script:
<script type="text/javascript"> document.getElementById('TextBox2').oncontextmenu = function (){ return false; }; </script>
The menu item is not displayed when false returned. Here is a browser overview for this:
http://help.dottoro.com/ljhwjsss.php
ntziolis
source share