• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 369
  • Last Modified:

How to disable right click on the .aspx page.

How to disable right click on the .aspx page thus disabling the user to view source.
0
searchsanjaysharma
Asked:
searchsanjaysharma
1 Solution
 
esolveCommented:
You can only achieve this by adding jscript to the page

<SCRIPT language=JavaScript>
	var message = "function disabled"; 
	function rtclickcheck(keyp){ if (navigator.appName == "Netscape" && keyp.which == 3){ 	alert(message); return false; } 
	if (navigator.appVersion.indexOf("MSIE") != -1 && event.button == 2) { 	alert(message); 	return false; } } 
	document.onmousedown = rtclickcheck;
</SCRIPT>

Open in new window


Some more examples here:

http://www.dynamicdrive.com/dynamicindex9/noright.htm
http://www.dynamicdrive.com/dynamicindex9/noright3.htm
0
 
informaniacCommented:
If your only goal is to disable the user from viewing the source, then that is technically impossible.

The user can simply install the firebug plugin for Firefox or use the IE Developer tools and view the source(and do much more)
0
 
Monica PCommented:
can use the script to make this done

just add this script in page where need to disable rightclick

<script language="JavaScript" type="text/javascript">

var message = "Right Click not allowed.";
function click(e) {
if (document.all) {
if (event.button == 2 || event.button == 3) {
alert(message);
return false;
}
}
else {
if (e.button == 2 || e.button == 3) {
e.preventDefault();
e.stopPropagation();
alert(message);
return false;
}
}
}
if (document.all) {
document.onmousedown = click;
}
else {
document.onclick = click;
}
</script>

Open in new window

0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
Monica PCommented:
To disable user from viewing the ViewSource is possible f process is on wholly from serverside

refer for more cleared suggestion
http://stackoverflow.com/questions/4967319/can-view-source-be-disabled-by-a-website
0
 
käµfm³d 👽Commented:
The user can simply install the firebug plugin for Firefox or use the IE Developer tools and view the source(and do much more)
On top of that, it's quite simple to download something like Fiddler or Wireshark and get access to the raw request--no browser or Javascript required.

As the others have said, what you are trying to do is not feasible to prevent anyone except the average user from seeing your HTML source.
0
 
searchsanjaysharmaAuthor Commented:
txc
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now