How to Disable Right Click Event ASP.Net Web Page ?

disable right click web page Right click event in web page allow user view page source , copy source code , save as page , copy css style sheet , copy javascript by disabling right click you can prevent miss use.
Copy javascript snippet at your master page at end of the body ,when user right click it will return false, best practice to copy java code at body end to prevent web page delay loading which is always good for SEO.This javascript code works in html, php, aspx

Download

Example Source Snippets -

Disable right click event in web page

   

         if (document.layers) {
             document.captureEvents(Event.MOUSEDOWN); //Capture the MouseDown event. 

             document.onmousedown = function () {
                 return false;  //Disable the OnMouseDown event handler.
             };
         }
         else {
             //Disable the OnMouseUp event handler.
             document.onmouseup = function (e) {
                 if (e != null && e.type == "mouseup") {

                     //Check the Mouse Button which is clicked.

                     if (e.which == 2 || e.which == 3) {
                         //check Button is middle or right then disable.
                         return false;
                     }
                 }
             };
         }
         //Disable the Context Menu event.
         document.oncontextmenu = function () {
             return false;
         };       

                    

smartsnipps.ecomparefiles.com © 2019, All Rights Reserved | Disclaimer: smartsnipps.eCompareFiles.com is free to use any code snippets without guarantee