JQuery to Disable Right Click Mouse Button on all Images in Asp.Net C# VB.Net

Sometimes we need to disable mouse right button on images to protect the resources. To protect image you need to take a lot of ways like making the images as background images, give watermark on the images etc. Protecting images, disabling mouse right click also a better way. That’s why in this post I will concentrate only on “Disabling Mouse Right Click using JQuery”.

Related Articles:
1. JQuery to Disable Right Click Mouse Button on a Specific Area of a Page in Asp.Net C# VB.Net
2. JQuery to Disable Right Click Mouse Button in Asp.Net C# VB.Net

Objective/Outcome:
JQuery to Disable Right Click Mouse Button on all Images in Asp.Net Csharp VB.Net

To do the Example set up some Images like below:

    <img src="Images/Flower1.jpg" border="2px" width="150px" height="100px"/><br /><br />
    <img src="Images/Flower2.jpg" border="2px" width="150px" height="100px"/><br /><br />
    <img src="Images/flower3.jpg" border="2px" width="150px" height="100px"/>

JQuery Code to Disable Mouse Right Button on Images of a Page:

<script type="text/javascript">
    $(document).ready(function () {
        $('img').bind('contextmenu', function (e) {
            alert('Sorry -- not acceptable !!');
            return false;
        });
    });  
</script>

Hope now you can disable the mouse right click on images of a web page.

Download Code Example C#        Download Code Example VB.Net

Posted in .Net, Asp.net, C#, Client, JQuery, VB.Net

Leave a Reply

Your email address will not be published. Required fields are marked *

     

*