Click here to Skip to main content
14,970,700 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
Updated 19-May-13 21:30pm

Follow this - Disable Backspace to Previous Page in Asp.Net[^].
The following code will allow backspace in textbox not on form. This code works perfectly in IE7/8,FireFox,Chrome
<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;   
<body onkeydown=cancelBack()>
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) :

document.onkeydown = function { return (event.keycode != 8); };
thank you very much for ur support
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.


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