Disable right click on SQL reporting services report in SharePoint 2007
September 20th, 2007 — ¥ong¥s
Free Link Exchange Software and Automate Link Swap Service
Offers free link swap service, link trade directory, reciprocal link exchange software that auto updates your link pages and complete link exchange. |
We are working on SharePoint Workspace with Business Intelligence solution. There some report build with reporting services show in SharePoint page. Then, we come across a special requirement that the client do not allow user to “Right click” on the entire SharePoint page including the reports. If you are using page viewer or report web part to view the report in native mode, you will never able to include your JavaScript to disable the right click. This is because it using iFrame to link to the report. To overcome this problem, there are 3 steps need to be done.
- Install and configure Reporting Services Add-in for SharePoint
First, we need to install the “Microsoft SQL Server 2005 Reporting Services Add-in for Microsoft SharePoint Technologies” add-in and change reporting services to SharePoint integration mode. You can download the add-in in https://www.microsoft.com/downloads/details.aspx?familyid=1E53F882-0C16-4847-B331-132274AE8C84&displaylang=en and get some introduction on its benefit here http://blogs.msdn.com/SharePoint/archive/2007/02/19/microsoft-sql-server-2005-sp2-reporting-services-integration-with-wss-3-0-and-moss-2007.aspx . You need to configure the reporting services after installed the add-in. You can easily find some help via google. Once done, you have to upload some report to SharePoint document library. - Add JavaScript to disable the right click on SharePoint.
To simplify the story, we use Content Editor Web Part to ad in the JavaScript. Enter code below in “Source Editor”:
<SCRIPT language=”JavaScript” >
function queryString(parameter) {
var loc = location.search.substring(1, location.search.length);
var param_value = false;
var params = loc.split(”&”);
for (i=0; i<params.length;i++) {
param_name = params[i].substring(0,params[i].indexOf(’='));
if (param_name == parameter) {
param_value = params[i].substring(params[i].indexOf(’=')+1)
}
}
if (param_value) {
return param_value;
}
else {
return false; //Here determine return if no parameter is found
}
}
function right(e) {
if (navigator.appName == ‘Netscape’ &&
(e.which == 3 || e.which == 2))
return false;
else if (navigator.appName == ‘Microsoft Internet Explorer’ &&
(event.button == 2 || event.button == 3)) {
alert(”Sorry, you do not have permission to right click.”);
return false;
}
return true;
}
document.onmousedown=right;
document.onmouseup=right;
if (document.layers) window.captureEvents(Event.MOUSEDOWN);
if (document.layers) window.captureEvents(Event.MOUSEUP);
window.onmousedown=right;
window.onmouseup=right;
</script>

The right click will disable on the specify page now.
- Add in SQL reporting Services Report Viewer Web Part to display report.
Add in the SQL reporting Services Report Viewer Web Part. Try to configure the web part and point to your report. If you leave all other setting as default, you will found that the right click is still enabling when we move to the report panel. To solve this, we need to uncheck the “Asynchronous Rendering” under “View” in the web part. This will make the whole page render at the same time. Now, try it out. It should work fine where the whole page including the report are not able to have right click anymore!




October 9th, 2007 at 12:55 pm
Can this be done for a picture library too? I would like to prevent people saving pictures of staff members from intranet portal.
October 9th, 2007 at 4:52 pm
Yes, you can use the same approach. Just simply add a content editor webpart with the javascript into the picture galery page. You may also add the javascript in the global sharepoint JS file. This step will apply the disable right click features to the whole site.
December 11th, 2007 at 9:34 pm
can you change the icon in the box to critical
December 11th, 2007 at 10:42 pm
Hi darkstar,
You can not change the default properties of alert, confirm, and prompt with JavaScript. You have to use VBScript or you need to build your own out of layers… Do post the solution here if someone knows how to change it…
August 17th, 2008 at 9:15 pm
[...] Read the rest of this entry (moved to http://www.bronios.com) » Posted in .Net, SSRS, SharePoint. [...]
February 7th, 2010 at 9:50 pm
Hi,
Can i disable right click on SSRS2008 in asp.net application in reportviewer control ?
August 15th, 2010 at 3:52 am
Hi ,
I had added the addin for ssrs webpart . I cannot find the report viewer properties i.e. asynchronous rendering property . I am using sharepoint 2007 and sql server 2005
Please help