How to make right click disable on image using java script in asp.net c#

In this article, I am trying to protect the image using disable right key of mouse.
Using this code we can protect particular image not whole form.

Source Code:-

<
html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title> image </title>

   
 <script type="text/javascript">
     function disableRightClick() {
         alert("Sorry,Right click is not allowed!!!");
         return false;
     }
</script>
</head>
<body >
    <form id="form1" runat="server">
    <div>
   
        <asp:Image ID="Image1" runat="server" ImageUrl="~/img/image.jpg"
            Width="317px" oncontextmenu=" return disableRightClick();" Height="84px"/>
        <br />
   
    </div>
    </form>
</body>
</html>

Out-Put:-


How to make right click disable on image using java script in asp.net c# How to make right click disable on image using java script in asp.net c# Reviewed by NEERAJ SRIVASTAVA on 9:51:00 PM Rating: 5

No comments:

Powered by Blogger.