Share Blog

Saturday, July 05, 2014

How TO Disable Right Click On Web Page(Web Site) Using Java Script

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <style type="text/css">
        .style1
        {
            width: 100%;
        }
        .style2
        {
        }
        .style3
        {
            width: 87px;
        }
    </style>
    <script language="javascript">
document.onmousedown=disableRightclick;
status="Right Click Disabled";
Function disableRightclick(event)
{
  if(event.button==2)
   {
     alert(status);
     return false;  
   }
}
</script>
</head>
<body oncontextmenu ="return false">
    <form id="form1" runat="server">
    <div>
   
        <table class="style1">
            <tr>
                <td class="style2" colspan="2">
                   
                
                    Disable Right Click</td>
            </tr>
            <tr>
                <td class="style3">
                    Username</td>
                <td>
                    <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td class="style3">
                    Password</td>
                <td>
                    <asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td class="style3">
                    &nbsp;</td>
                <td>
                    &nbsp;</td>
            </tr>
            <tr>
                <td class="style3">
                    <asp:Button ID="Button1" runat="server" onclick="Button1_Click"
                        Text="Change Password" />
                </td>
                <td>
                    <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
                </td>
            </tr>
        </table>
   
    </div>
    </form>
</body>

</html>

No comments:

Post a Comment