Disable of viewing previous page in asp.net

In my project i want to deny going back to the page when i click back button in toolbar. How its possible in asp.net and c#. Thank you.

Answers:

Answer

Just put this javascript in the html section of an aspx page above the head section.

This causes every back to return with a forward.

<script type = "text/javascript" >
function disableBackButton()
{
window.history.forward();
}
setTimeout("disableBackButton()", 0);
</script>

plus have a look at this article http://www.4guysfromrolla.com/webtech/111500-1.shtml

Answer

If you want to do this by code-behind.Put following code in Page_Load or Page_Init event of the page

protected void Page_Init(object Sender, EventArgs e)
{
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.Cache.SetExpires(DateTime.Now.AddSeconds(-1));
Response.Cache.SetNoStore();
}

Tags

Recent Questions

Top Questions

Home Tags Terms of Service Privacy Policy DMCA Contact Us Javascript

©2020 All rights reserved.