Click here to Skip to main content
15,891,033 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi Team,

Your interest in solving doubts is appreciated.By the way,Could you please provode "Right click disabled" code in javascript for simple login application.

Requirement:When we Right click on password field,the alert message should be displayed as right click disabled.




Please do this needfull.



Thanks
Posted
Comments
Sergey Alexandrovich Kryukov 2-May-12 1:31am    
Makes little to no sense. Why doing so?
--SA

You have to do use the following solution:

Client Side:

XML
<script>
    function DisableRightClick(event) {

        if (event.button == 2) {  //For mouse right click
            alert("Sorry, Right Click not allowed!!!");
        }
    }
    
</script>



Server Side:

C#
if (!Page.IsPostBack)
            {
                TextBox1.Attributes.Add("onmousedown", "DisableRightClick(event)");
            }
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900