C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Resources » Articles » ASP.NET/Web Applications »

Step By Step approach to disable Right Button Click in ASP.NET


Posted Date: 08 Nov 2004    Resource Type: Articles    Category: ASP.NET/Web Applications
Author: S. SureshMember Level: Gold    
Rating: 1 out of 5Points: 5



Introduction

This article explains how not to allow an user to do right click on the ASP.NET web page. This is very simple to achieve.

Step-By-Step:

1. Go the web page in which you want to disable right click.

2. Goto HTML part of the code by clicking the HTML tab in VS.NET IDE.

3. Add the following code in HTML page.

<script language=javascript>
<!--
function DisableRightClick()
{
if (event.button == 2)
{
alert("Right Click is disabled.")
}
}
document.onmousedown=Disable;
//-->
</script>


4. Now run the page and try right clicking on the page. It will display the alert message given in the function.


Conclusion:
Hope this one comes handy to people who are looking for disabling right click.

Thanks,
S Suresh



Responses

Author: Rajasekaran Ponnusamy    10 Nov 2004Member Level: Silver   Points : 0
Hi Suresh,
I read well in your article. It's nice. But one mistake(big). You didn't put any code here.
Rajasekaran P


Author: S. Suresh    15 Nov 2004Member Level: Gold   Points : 0
Hi Raj...I've not given the entire page for users. I've just given the code snippet. Just just use the code snippet in your page and try.
Do let me know if you have any other help.
THanks.
S Suresh


Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Sign In to add tags.
(No tags found.)

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: Setting User control properties contd with the HTML
Previous Resource: Paging in ASP.NET Part I
Return to Discussion Resource Index
Post New Resource
Category: ASP.NET/Web Applications


Post resources and earn money!
 
More Resources



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use