Follow in Twitter & Facebook


Like in Facebook

Powered By Blogger Widgets

Free Download

FREE Tools


Friday, August 24, 2012

Disable right click by using jQuery in asp.net

In this article we will discuss how we can disable right click using jQuery. You can also check my laste article on how to open hyperlink in new tab window using jQuery here.

In most of the pages sometime we required to disable right click option. We can do it easiy using jQuery. Below is the code:
.aspx code:

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="DisableRightClick.aspx.cs"
Inherits="DisableRightClick" %>
<!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 runat="server">
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js"></script>
<title>Disable right click using jquery in asp.net</title>

<script type="text/javascript" language="javascript">
$(function () {
$(this).bind("contextmenu", function () {
return false
});
});

</script>
</head>
<body>
<form id="form1" runat="server">
<div>Warning: Right click is disabled so do not try !!!
</div>
</form>
</body>
</html>

In the above code 2 things are important first is the jQuery function and 2nd one is the jQuery library reference.
You can also check some SQl Server articles and interview questions.




0 on: "Disable right click by using jQuery in asp.net"