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.
Description:
Demo:
Description:
In Previous articles I have explained What are the Magic tables or Logical Tables in SQL server and how to
access Magic Tables? And Explain CTE (Common Table expression) in sql databse? And string VS string builder in ASP.NET (c#)
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:
<script>
function
disRightClick() {
alert("Right
click is not allowed !!");
return
false;
}
</script>
|
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.