Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# Javascript
i have to disable back button f my browser. I tried many codes searched in google. but its not working for all browsers. Can anyone help me to find the correct code for it?
Posted 22-Aug-11 2:05am
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

  Permalink  
Comments
Aswathi Narayan at 22-Aug-11 7:11am
   
Thank u 4 ur reply.. But i have to disable it in every page of my project. How can i do this?
Pravin Patil, Mumbai at 22-Aug-11 7:18am
   
Nice link..
My 5....
kishore doni at 29-Aug-12 7:05am
   
Its nice
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 4

Please have a look at my answer to a similar question earlier
 
How to disable back,forward and Refresh functionality in browser?[^]
 
In short, don't disable the back button - it's not yours to disable. If you're trying to do this because your application 'needs it', then your architecture and general approach is probably incorrect
 
"..But i have to disable it in every page of my project. How can i do this?"
 
Why would you ever need to do this? What about if you were on codeproject now and you couldn't use back or any navigation functions, wouldn't you be annoyed?!
 
If you really want to stop users being able to go back, you could use an approach similar to this link
 
http://www.codeguru.com/csharp/.net/net_debugging/debugging/article.php/c12891[^]
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 6

Have a look at this,
 
http://aspnetstudymaterials.blogspot.in/2011_11_01_archive.html[^]
 
You have to paste the code in the master page or all of your pages...
Thank you...
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

Check out :
 
1. http://www.htmlgoodies.com/tutorials/buttons/article.php/3478911/Disabling-the-Back-Button.htm[^]
2. http://csharpdotnetfreak.blogspot.com/2009/04/disable-browser-back-button-javascript.html[^]
3. http://www.4guysfromrolla.com/webtech/111500-1.shtml[^]
4. http://www.irt.org/script/311.htm[^]
 
You can write this functionality on the page where you want back button disabled. If you want all the pages to have back button disabled then the same function can be written in Master Page.
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

you can check prevoius page via server[page_referrer] in your page, redirect to error page if the previous page is not your desired one.
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 8

Just use this code into your Page Load Event:
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.Cache.SetExpires(DateTime.UtcNow.AddHours(-1));
Response.Cache.SetNoStore();
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 5

Add this script:
 
<script>history.go(1)</script>
 
on Head section of page. Hope this will help you
  Permalink  
Comments
member60 at 28-Apr-12 5:57am
   
!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 295
1 Maciej Los 280
2 Afzaal Ahmad Zeeshan 224
3 BillWoodruff 205
4 Sergey Alexandrovich Kryukov 195
0 OriginalGriff 6,499
1 Sergey Alexandrovich Kryukov 6,048
2 DamithSL 5,193
3 Manas Bhardwaj 4,657
4 Maciej Los 4,120


Advertise | Privacy | Mobile
Web01 | 2.8.1411019.1 | Last Updated 18 Apr 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100