Thursday, May 28, 2009

Disable Back button of Internet Explorer..

1: Purpose:

Some times we want user should not go back by clicking Back button of Internet Explorer. so here is the Java Script which we can write on master.aspx file in head section:

(Left Anchor Brkt) head (Right Anchor Brkt)
(Left Anchor Brkt) script language="javascript" type="text/javascript"(Right Anchor Brkt)
window.history.forward (1);
(Left Anchor Brkt) /script (Right Anchor Brkt)
(Left Anchor Brkt) /head (Right Anchor Brkt)

I m sorry to say the editor is not allowing Anchor bracket so u just implement..



2: Purpose:

Sometimes user should not go back after clicking logout Button..

protected void LinkLogoutBtn_Click(object sender, EventArgs e)
{
Session.Abandon();
Session["name"] = "";
Response.Cache.SetExpires(DateTime.UtcNow.AddMinutes(-1));
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.Cache.SetNoStore();

Response.Redirect("logon.aspx");
}


Code description:
Here I write this code in Logout buton click event and when the user click logout i am clearing the cache and redirecting the user to Logon.aspx page..

No comments:

Bookmark and Share