Aspdotnet-Suresh

aspdotnet-suresh offers C#.net articles and tutorials,csharp dot net,asp.net articles and tutorials,VB.NET Articles,Gridview articles,code examples of asp.net 2.0 /3.5,AJAX,SQL Server Articles,examples of .net technologies

Disable right click on images using jquery in asp.net

Aug 11, 2012
Introduction

Here I will explain how to disable right click on right click only on images using JQuery in asp.net.

Description:
  
In previous article I explained disable right click web page using JQuery. Now I will explain how to disable right click only on images using
JQuery in asp.net.

To implement this one we need to write code as shown below in your aspx page


<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>jQuery disable right click on webpage using asp.net</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js">
</script>
<script type="text/javascript" language="javascript">
$(function() {
$('img').bind("contextmenu", function() {
return false
});
});
</script>
</head>
<body>
<form id="form1" runat="server">
<img src="https://lh5.googleusercontent.com/_B28NJpJ61hA/TdgnS7lh7mI/AAAAAAAAAi4/oLTicIRgEIw/FinalLogo.png" alt="Aspdotnet-Suresh" />
<div>
Aspdotnet-Suresh offers Asp.net,C#.net,SQL Server,Web Services,WCF,
WPF,MVC,Crystal Reports,AJAX,XML,JavaScript,JQuery,Gridview articles,
samples and tutorials,code examples of asp.net 2.0,3.0,3.5,4.0 and Articles,
examples of .net technologies
</div>
</form>
</body>
</html>
If you observe above code in header section I added script file link by using that file we have a chance to interact with JQuery and in the script we have bind event with contextmenu which is used to disable right click on images based using JQuery in asp.net.

Demo

To test this demo right click on the below logo(Aspdotnet-Suresh) you won’t get any right click and now go to the text below the logo(Aspdotnet-Suresh) and try to right click now you are able to get right click in this way we can restrict right click for images 

 Aspdotnet-Suresh
Aspdotnet-Suresh offers Asp.net,C#.net,SQL Server,Web Services,WCF, WPF,MVC,Crystal Reports,AJAX,XML,JavaScript,JQuery,Gridview articles, samples and tutorials,code examples of asp.net 2.0,3.0,3.5,4.0 and Articles, examples of .net technologies

If you enjoyed this post, please support the blog below. It's FREE!

Get the latest Asp.net, C#.net, VB.NET, jQuery, Plugins & Code Snippets for FREE by subscribing to our Facebook, Twitter, RSS feed, or by email.

subscribe by rss Subscribe by RSS subscribe by email Subscribe by Email

5 comments :

Vishal Raviya said...

I Wana Provide Secuirty When Webpage Saveas Tht Time also Photo Is Not Download....
In Short End User Can't Download Photo Anyway..

Abhinavsingh993 said...

What is intresting about you sir "Aap Gyan ka sagar ho mai ek pyasa." you have each and everything that I need to know , You are my Real Guru by reading your website I got placed in a reputed software company ,
Thanks and Regards,
Er. Abhinav Kumar Singh
To whom without who thought me everything aboout ASP.NET

Seema Wadkar said...

thanks a lot

Vikramraj Patil said...

Your all articles are very useful covers most of …
THANK YOU.

MAHENDRA KAMBLE said...

If I drag that image on new tab on browser, then I am able to save that image. There should be security like right click should disable, and also no one can drag that image from web page to other tab..

Give your Valuable Comments

Other Related Posts

© 2010-2012 Aspdotnet-Suresh.com. All Rights Reserved.
The content is copyrighted to Suresh Dasari and may not be reproduced on other websites without permission from the owner.