Click here to Skip to main content
15,886,199 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How to disable mouse right click's options on a web page using C#.
Posted
Comments
Philippe Mori 24-Nov-12 9:01am    
Even though it is relatively easy to disable right mouse click, it has very little benefit as it is very easy to display the menu anyway... and it is also very easy to display the source code of the site without using right mouse click. So in the end, it is almost useless to do that if the purpose is too increase your site security.

hi dear
use below javascript on your web page
XML
<SCRIPT TYPE="text/javascript">
<!--
//Disable right click script
//visit http://www.rainbow.arch.scriptmania.com/scripts/
var message="Sorry, right-click has been disabled";
///////////////////////////////////
function clickIE() {if (document.all) {(message);return false;}}
function clickNS(e) {if
(document.layers||(document.getElementById&&!document.all)) {
if (e.which==2||e.which==3) {(message);return false;}}}
if (document.layers)
{document.captureEvents(Event.MOUSEDOWN);document.onmousedown=clickNS;}
else{document.onmouseup=clickNS;document.oncontextmenu=clickIE;}
document.oncontextmenu=new Function("return false")
// -->
</SCRIPT>
 
Share this answer
 
Comments
Dee_Bee 24-Nov-12 1:14am    
Can't I do it in server side using C#? in code behind(.cs file)?
Hi try this out,
HTML
<body oncontextmenu="return false">
</body>

--Sowraaj
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900