ASP.NET:Disable right click on images to prevent images from being copied or stolen.

Aman Sharma
Images in our websites are not secure. Someone can easily copy them from the website. But sometime it is needed to prevent Images on website from being copied or stolen. To prevent images from being stolen we have to disable right click on the page or on particular image.

We can secure our images by disabling right click on images. This is effective and simple technique to achieve this.



In this article I will explain how to disable right click on image. I will add event handler to disable right click as given below:

Right Click Disable on Images:

<asp:Image ID="Image1" runat="server" ImageUrl="~/1978215.jpg"
            oncontextmenu="return false;" Height="185px" Width="305px"/>
<img src="1978215.jpg" style="width: 305px" oncontextmenu="return false;"/>

We can show alert on trying right clicking on images by using javascript:

        function disRightClick() {
            alert("Right click is not allowed !!");
            return false;

    Call this Function on “oncontextmenu” event of Image:

<img src="1978215.jpg" style="width:305px" oncontextmenu="return disRightClick();"  />

Note: Images are not secure on websites. There are no of tools and software through which one can copy your images easily. 

Post a Comment

Post a Comment (0)

#buttons=(Accept !) #days=(20)

Our website uses cookies to enhance your experience. Learn More
Accept !