Click here to Skip to main content
15,887,450 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hey programmers,

Please share what u know about the following issue on C#.


I have a master page in which there are many controls including Home and Logout button. When I Press Backspace Key the page redirects to the Login page.
Please forward your answers, thank you
Posted
Updated 19-May-13 21:30pm
v2

Follow this - Disable Backspace to Previous Page in Asp.Net[^].
Quote:
The following code will allow backspace in textbox not on form. This code works perfectly in IE7/8,FireFox,Chrome
HTML
<script language=javascript>   
            
    function cancelBack()   
    {   
        if ((event.keyCode == 8 ||    
           (event.keyCode == 37 && event.altKey) ||    
           (event.keyCode == 39 && event.altKey))   
            &&    
           (event.srcElement.form == null || event.srcElement.isTextEdit == false)   
          )   
        {   
            event.cancelBubble = true;   
            event.returnValue = false;   
        }   
    }   
  
</script>   
<body onkeydown=cancelBack()>
 
Share this answer
 
Backspace does not specifically redirect to a "login" page but to your latest page in the History stack...
If you want to prevent this you can do it via javascript by catching onKeyPress and returning false ik ascii code is 8 (backspace).

try this (untested) :

JavaScript
document.onkeydown = function { return (event.keycode != 8); };
 
Share this answer
 
thank you very much for ur support
 
Share this answer
 
Comments
Most welcome... I guess you want to thank all, but added one answer by mistake.
So, please delete this. And if you want to thank or comment on any answer, then click on "Have a question or Comment" inside the answer box itself.

Thanks,
Tadit

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