Thursday, October 14, 2010

Preventing browser back button functionality

In page load event ,b4 if(!ispostback) checking
------------------------------------------------

public void AvoidCache()

{

Response.Cache.SetNoStore();

Response.Cache.SetExpires(DateTime.Now.AddSeconds(-1));

Response.Cache.SetCacheability(HttpCacheability.NoCache);

Response.Cache.SetValidUntilExpires(false);

}





OR





put this code in B4 the header tag in Default.aspx page.

------------------------------------------------------------



script type = "text/javascript" > //script for preventing browser back button functionality(Akbar)

function preventBack() { window.history.forward(); }

setTimeout("preventBack()", 0);

window.onunload = function() { null };

/script>

No comments: