In this article I will explain with an example, how to disable mouse right click in ASP.Net (.aspx) page using JavaScript.
 
 
JavaScript Script to disable Right Click
Inside the oncontextmenu event handler, the event is cancelled by returning FALSE.
<script type="text/javascript">
    //Disable the Context Menu event.
    document.oncontextmenu = function () {
        return false;
    };
</script>
 
 
Disabling Mouse Right Click in ASP.Net using JavaScript
You will need to place the following script in HEAD section of your ASP.Net (.aspx) page or Master Page (.master).
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <script type="text/javascript">
        //Disable the Context Menu event.
        document.oncontextmenu = function () {
            return false;
        };
    </script>
</head>
<body>
    <form id="form1" runat="server">
        <h1>Try to Right Click on this Page.</h1>
    </form>
</body>
</html>
 
 
Screenshot
Disable Mouse Right Click in ASP.Net using JavaScript
 
 
Browser Compatibility
The above code has been tested in the following browsers.
Microsoft Edge  FireFox  Chrome  Safari  Opera
* All browser logos displayed above are property of their respective owners.
 
 
Demo
 
 
Downloads