About the author

Vijay Kodali
E-mail me Send mail

Site Statistics

Site Meter

Recent comments

Authors

Disclaimer

The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

© Copyright 2017

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;   
        }   
    }   
  
</script>   
<body onkeydown=cancelBack()>   

Tags:
Categories: ASP.Net 3.5 | JavaScript
Posted by vijay on Tuesday, September 02, 2008 9:50 AM
Permalink | Comments (6) | Post RSSRSS comment feed

Comments

Kay Nelson Sweden

Wednesday, February 22, 2012 6:23 AM

Kay Nelson

Perfect! This solved my issue. Had a textbox in update panel that caused bowser to go back 1 page instead of being albe to amend the textbox value.

thanks!!!!

Shankar V India

Wednesday, August 01, 2012 3:14 AM

Shankar V

Hi Its working in IE 6 too...Usefull for everyone...

Toro Kambali United States

Friday, August 17, 2012 7:06 AM

Toro Kambali

Hi Vijay, I use the script on  IE9 and Chrome and it works perfectly. Muchas Gracias!

por United States

Monday, February 04, 2013 12:53 PM

por

Excellent, It worked for me.

prasad India

Thursday, May 02, 2013 4:17 AM

prasad

Hi.. Its working fine in IE but not in Firefox..

Diptej Thakkar India

Saturday, July 06, 2013 1:24 AM

Diptej Thakkar

This Code is Working Properly in all browsers. but when i pressed the back button which is available on browser. that time this code is not working. so can u help me its urgent...

Add comment


(Will show your Gravatar icon)

  Country flag

biuquote
  • Comment
  • Preview
Loading