Solved

How to disable right click on the .aspx page.

Posted on 2013-02-02
6
356 Views
Last Modified: 2013-02-21
How to disable right click on the .aspx page thus disabling the user to view source.
0
Comment
Question by:searchsanjaysharma
6 Comments
 
LVL 6

Accepted Solution

by:
esolve earned 500 total points
ID: 38846811
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
 
LVL 20

Expert Comment

by:informaniac
ID: 38847833
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
 
LVL 10

Expert Comment

by:Monica P
ID: 38848616
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 10

Expert Comment

by:Monica P
ID: 38850245
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
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 38852127
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
 

Author Closing Comment

by:searchsanjaysharma
ID: 38913934
txc
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
XAML: Layout 8 25
Any Third party toll for Integrating chat system on ASP.NET ? 2 34
Runtime Error 2 27
Angular - break the dataset in chunks? 7 38
A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…
I designed this idea while studying technology in the classroom.  This is a semester long project.  Students are asked to take photographs on a specific topic which they find meaningful, it can be a place or situation such as travel or homelessness.…

932 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now