This article explains how to disable the right-click function using jQuery. We can prevent right-click using jQuery in many ways. In this article we will explain two ways to prevent right-click function using jQuery. Here, we will create a website application and add a new page to the website. After that drag and drop an image control onto the page and using jQuery we disable right-click. If you like to add this feature to your site, then follow the steps below.
First you have to create a web site.
- Go to Visual Studio 2010
- New-> Select a website application
- Click OK

Now add a new page to the website.
- Go to the Solution Explorer
- Right-click on the Project name
- Select add new item
- Add new web page and give it a name
- Click OK

Now the script code, which you have to add inside the <script></script> tags, will be paced either in the head section or the body section as you prefer.
<script type="text/javascript" src="Scripts/jquery-1.4.1.min.js"></script>
Step 1 : We just need to bind the contextmenu event with the document element. In the head section we copy the following code.
<script type="text/javascript" language="javascript">
$(function () {
$(this).bind("contextmenu", function (e) {
e.preventDefault();
});
});
</script
In this step we will see the complete code for the .aspx page; let us see the code given below.
Code
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="disableclick.aspx.cs" Inherits="disableclick" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<script type="text/javascript" src="Scripts/jquery-1.4.1.min.js"></script>
<script type="text/javascript" language="javascript">
$(function () {
$(this).bind("contextmenu", function (e) {
e.preventDefault();
});
});
</script
</head>
<body>
<form id="form1" runat="server">
<div>
<h3>
Disable Right Click</h3>


FAROOKH MANSURIPosted May 22, 2015, 3:23 AM
nice one.........
SIVAPosted Mar 12, 2012, 10:37 AM
Hi.. Its nice article.. Can you post article to restrict Ctrl+S also