Click here to Skip to main content
15,892,697 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello friend,

I am using Asp.net framework 3.5,i want to disable brower's back button.
if any body having solution,please let me know.

Thank's in Advance.
Posted

 
Share this answer
 
v2
Comments
Uday P.Singh 9-Sep-11 5:58am    
my too 5!
check this out:

Browser back button issue after logout[^]

hope it helps :)
 
Share this answer
 
Comments
Prerak Patel 9-Sep-11 5:53am    
Nice link, +5
To add to Prerak's answer, have a look at following links :
1. Three ways to disable browser back button[^]
2. Use Javascript to restrict user from pressing back button in browser[^]
3. A Thorough examination of browser back button[^]
4. Simple solution[^]

Many of the experts suggest not to disable expected browser behaviour. Instead make your pages handle the possibility of users going back. In other words redirect the user to certain page when user tries to press back button.

Hope this helps.
All the best.
 
Share this answer
 
Try this code also

JavaScript
<script type="text/javascript" language="javascript">
window.history.forward(1);
document.attachEvent("onkeydown", my_onkeydown_handler);
function my_onkeydown_handler()
{
switch (event.keyCode)
{
case 116 : // F5;
event.returnValue = false;
event.keyCode = 0;
window.status = "We have disabled F5";
break;
}
}
</script>


and use this one in code behind

C#
Session.Clear();
Session.Abandon();

Happy code....
 
Share this answer
 
v2
Comments
syed armaan hussain 3-May-12 17:17pm    
and what if user has blocked script at his browser
Member 8491154 12-Jul-12 5:29am    
Where do we have to use the code behind code? In the login page?
On code behind write this:

C#
protected void Page_Load(object sender, EventArgs e)
   {
      
     HttpContext.Current.Response.Cache.SetCacheability(HttpCacheability.NoCache);
     HttpContext.Current.Response.Cache.SetNoServerCaching();
     HttpContext.Current.Response.Cache.SetNoStore();
    

   }



and on client side write something like this:

XML
<script type="text/javascript" language="javascript">
window.history.forward(1);
document.attachEvent("onkeydown", my_onkeydown_handler);
function my_onkeydown_handler()
{
switch (event.keyCode)
{
case 116 : // F5;
event.returnValue = false;
event.keyCode = 0;
window.status = "We have disabled F5";
break;
}
}
</script>
 
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