Introduction
In this article we will learn how to disable the mouse right click using jQuery which provides security to our HTML source code along with providing the security by being copied or pasted directly in form control.
Note
- To use jQuery in an ASP.Net form you need to add the reference for the jQuery library that is nothing but a JavaScript file.
- You can download the latest jQuery library from http://jquery.com/download/.
I hope, you have downloaded the above jQuery library for referencing a page because whenever we use any jQuery code then it must give the jQuery library file reference into the page.
Let us Create the web application in asp.net to demonstrate the requirement by creating the web application as
- “Start” – “All Programs” – “Microsoft Visual Studio 2010″
- “File” – “New Website” – “C# – Empty website” (to avoid adding a master page).
- Give the web site a name, such as Validation or whatever you wish and specify the location.
- Then right-click on the solution in the Solution Explorer then select “Add New Item” – “Default.aspx page”.
I hope,you have created the page now, let us create the Jquery function to disable the mouse write click as
$(function()
{
$(this).bind(“contextmenu”, function(e)
{
e.preventDefault();
});
});
now add the jQuery library file reference at the head section of the page, the jquery function and jQuery library file will look like the following:
<head id=”Head1″ runat=”server”>
<title></title>
<script src=”Jquery-1.8.0.min.js” type=”text/JavaScript“></script >
<script type=”text/JavaScript”>
$(function()
{
$(this).bind(“contextmenu”, function(e)
{
e.preventDefault();
alert(“right click is disabled”); //not recommended to give alert message
});
});
</script >
</head>

Rohit PahujaPosted Aug 26, 2016, 7:14 AM
Great Article i have learned so many things from your article Please check this and tell me more about it: http://seowebsitedesigning.com/disable-mouse-right-click-using-jquery/