Email: Password:       Forgot Password 
A Saarsha Group Online Community for dot net codes group like C#, Asp.NET, VB.NET, Sharepoint, JavaScript, JQuery, Ajax, SQL, WCF, WPF.

Disable Right click on Web Page and images in ASP.NET

Viewed:  1874 
Posted On:  19/02/2014 07:01:55 
How we can disable Right Click on any aspx page or any image in ? 


In this article I am going to show how we can disable right click on our web form or images in

 To disable Right Click on an image:

    <asp:Image ID="MyImage1" runat="server" ImageUrl="Image/1.png"  oncontextmenu="return false;" />

    <img alt="MyImage2" src="Image/2.png" oncontextmenu="return false;"/>

To Disable Right Click on ASPX page:

<body oncontextmenu="return false;">
    <form id="form1" runat="server">
        <img alt="MyImage" src="2.jpg" />

If You want to show some error or warning message the use the below code:

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<html xmlns="">
<head runat="server">
    <title>Make Right Click Disabled</title>
    <script type="text/javascript">
        function MakeDisableRightClick() {
            alert("Hi.. Right Click is not permitted...");
            return false;
<body oncontextmenu=" return MakeDisableRightClick();">
    <form id="form1" runat="server">
        <img alt="MyImage" src="2.jpg" />

When Run the Programme:

Disable Right Click.png

Image 1.

         HOME   |   Submit Article   |   Contact Us   |   About Us   |   Terms & Condition   |   Advertise With us