Click here to Skip to main content
14,937,943 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
I used the following code to disable my browser back button but button is still working. plz help me out
C#
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.Cache.SetExpires(DateTime.UtcNow.AddHours(-1));
Response.Cache.SetNoStore();
Posted
Updated 9-Nov-11 20:17pm
v2
Comments
RaviRanjanKr 10-Nov-11 7:11am
   
A suggestion :- Never try to use Short texts like plz instead of Please.

   
Comments
RaviRanjanKr 10-Nov-11 7:11am
   
Nice Link, My 5+
sravani.v 10-Nov-11 7:16am
   
Thank you Ranjan....
Hi

you can restrict the user to go back with Backspace key by using following javascript...


<script type="text/javascript" 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;   
        }   
        
        if (window.event.keyCode == 13) 
        {
            event.returnValue=false; 
            event.cancel = true;
        }
    }   
    </script>
   
Comments
abhishekagrwl25 10-Nov-11 2:28am
   
Thanks for the ans sir,

But what if the user has disabled his java script ???? this would pose a problem then ...
abhishekagrwl25 10-Nov-11 2:45am
   
Also the code is not working
   
Comments
abhishekagrwl25 10-Nov-11 3:26am
   
tried all the solutions , none is working .
you need to use javascript. check the following

<body onunload="javascript:history.go(1)">


<body onLoad="javascript:window.history.forward(1)">
   

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