Home > DeveloperSection > Forums > How to Disable right click on body and images in web application.
Ankit Singh

Total Post:341

Posted on    January-03-2016 9:29 PM

 ASP.Net ASP.Net  Mvc  Web Application 

 1 Reply(s)
 513  View(s)
Rate this:
I want to Disable right click on body and images in web application .how to do this please help me.

aditya kumar Patel

Total Post:254

Posted on    January-03-2016 9:52 PM

Sometimes we required to prevent our web page images from being copied by another Persion.in that case we can secure our images by disabling right click or
 by disabling image context menu on images only. This is an effective approach to prevent our images from being copied  .Add the below event handler to the img  tag  and body as shown below:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Fourm.aspx.cs" Inherits="Forumasp.Fourm" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
    <script type="text/javascript">
        function disableRightClick() {
            alert("Sorry, right click is not allowed !!");
            return false;
    <meta charset="utf-8">
    <title>jQuery UI Menu - Categories</title>   
<body  oncontextmenu="return disableRightClick()" >
<img alt="Image" src="Images/1.jpeg" oncontextmenu="return disableRightClick()"/>




Don't want to miss updates? Please click the below button!

Follow MindStick