Answered Disable Right click in SSRS Report

  • jueves, 12 de julio de 2012 6:25
     
     

    Hi,

    I have a requirement to disable right click in an SSRS report, i tried to implement this using the javascript code mentioned below, however this is not working as expected, i am still able to right click the report and view properties, Currently i am displaying the report in IFrame from my ASP.Net application.

    <!--
    if (window.Event)
    document.captureEvents(Event.MOUSEUP);
    function nocontextmenu(){
    event.cancelBubble = true
    event.returnValue = false;
    return false;
    }
    function norightclick(e){
    if (window.Event){
       if (e.which == 2 || e.which == 3)
       return false;
    }
    else
       if (event.button == 2 || event.button == 3){
        event.cancelBubble = true
        event.returnValue = false;
        return false;
       }
    }
    document.oncontextmenu = nocontextmenu; // for IE5+
    document.onmousedown = norightclick; // for all others
    //-->


    when i tried to run the code as HTML file i can see the right click option being disabled which is working as expected, i am facing issues when calling the code from SSRS report

    <script type="text/Javascript">
    if (window.Event)
        document.captureEvents(Event.MOUSEUP);
    function nocontextmenu()
    {
        event.cancelBubble = true
        event.returnValue = false;
        alert("YOu are not allowed to perform this action");
        return false;
    }
    function norightclick(e) {
        if (window.Event) {
            if (e.which == 2 || e.which == 3)
         alert("YOu are not allowed to perform this action");
                return false;
        }
        else
            if (event.button == 2 || event.button == 3) {
                event.cancelBubble = true
                event.returnValue = false;
         alert("YOu are not allowed to perform this action");
                return false;
            }
    }
        document.oncontextmenu= nocontextmenu; // for IE5+
        document.onmousedown = norightclick; // for all others
    </script>

    Ramasubramanian S


Todas las respuestas

  • viernes, 13 de julio de 2012 7:15
     
      Tiene código

    Try this:

    <script type="text/jscript">
      function disableContextMenu()
      {
        window.frames["fraDisabled"].document.oncontextmenu = function(){alert("No way!"); return false;};   
        // Or use this
        // document.getElementById("fraDisabled").contentWindow.document.oncontextmenu = function(){alert("No way!"); return false;};;    
      }  
    </script>

  • martes, 17 de julio de 2012 9:19
     
     Respondida

    Hi,

    Thanks for the help rendered, i added the JavaScript file directly to the source file Reportviewer.aspx which is automatically generated by the Report Server, i could disable right click without any issues.

    Regards,

    Ramasubramanian.S


    Ramasubramanian S