Click here to Skip to main content
15,890,741 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
how to disable the back button of an asp.net page?
i want to disable it as in it may not show the previous page from browser's cache.. but reloads the previous page and show the updated version of it... the browser's button is still active but i want to reload the previous page if back button is clicked...
Posted
Updated 24-Nov-11 21:57pm
v2
Comments
rajeevcapgeminiindia 24-Nov-11 3:03am    
Are you talking about Browser Back button or some user defined button??
Sachin gulati 24-Nov-11 8:16am    
i'm talking about the browser's back button.. i want to disable it as in it may not show the previous page from browser's cache.. but reloads the previous page and show the updated version of it... the browser's button is still enable but i want to reload the previous page if back button is clicked...

If you mean to say - "Disable Browser's back button", then have a look at several Question-Answer discussions posted on CodeProject earlier on this topic.

http://www.codeproject.com/search.aspx?q=disable+back+button+%2b+asp.net&usfc=false&doctypeid=4%3b5
 
Share this answer
 
v2
C#
Response.Cache.SetCacheability(System.Web.HttpCacheability.NoCache);
        Response.AddHeader("pragma", "no-cache");
        Response.AddHeader("Cache-Control", "no-cache");
        Response.CacheControl = "no-cache";
        Response.Expires = -1;
        Response.ExpiresAbsolute = DateTime.Now.AddSeconds(-1);
        Response.Cache.SetNoStore();
 
         Page.ClientScript.RegisterStartupScript(this.GetType(), "cle", "windows.history.clear", true);

Or Use Javascript
C#
<script> 
function noBack(){window.history.forward();}
noBack();
window.onload=noBack;
window.onpageshow=function(evt){if(evt.persisted)noBack();}
window.onunload=function(){void(0);}
</script></script>

Check this link for more information
 
Share this answer
 
Comments
Sachin gulati 24-Nov-11 3:43am    
actually i dont want to disable history hence no back is available. i want that whenever user click back button it reloads the previous page inspite of taking it from the browser cache....
 
Share this answer
 
v2
XML
Response.Write("<script>window.top.navigate('../login.aspx')</script>");


hope it may may help u
 
Share this answer
 
Comments
Sachin gulati 24-Nov-11 8:12am    
actually i want to disable back button so that every time a user click on back button it does not show the previous page from the browser's cache.. but reloads the previous page and show the updated version of the page....
Try this javascript:

XML
<script language="JavaScript">

  javascript:window.history.forward(1);

</script>


Hope it solves your problem :)

Regards,
Eduard
 
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