I want to disable back button in the menu bar so that a user does not go to the previous page
I have been searchiong net for a solution.
I have found many suggestions but none seems to work for me.
To prevent a user from goin to previous page< I have, on my aspx page
<head runat="server">
<title><title>
<script type="text/javascript">
function DisableBackButton()
{
window.history.forward()
}
DisableBackButton();
window.onload = DisableBackButton;
window.onpageshow = function (evt) { if (evt.persisted) DisableBackButton() }
window.onunload = function () { void (0) }
<script>
</head>
<body önunload="disableBackButton()">
</body>
In my aspx.cs page i have the code behind
protected void Page_Load(object sender, EventArgs e)
{
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.Cache.SetExpires(DateTime.Now.AddSeconds(-1));
Response.Cache.SetNoStore();
Response.ExpiresAbsolute = DateTime.Now.AddSeconds(-1d);
Response.Expires = -1500;
Response.CacheControl = "no-cache";
Page.Response.Cache.SetCacheability(HttpCacheability.NoCache);
}
It has not worked. the back button still takes it to previous page.
I have also tried
protected void Page_Init(object sender, EventArgs e)
{
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.Cache.SetExpires(DateTime.Now.AddSeconds(-1));
Response.Cache.SetNoStore();
}
I have also tried with the above code
protected override void OnPreRender(EventArgs e)
{
string strDisAbleBackButton = "";
ClientScript.RegisterClientScriptBlock(this.GetTyp(), "clientScript",strDisAbleBackButton);
}
But nothing seems to work
Finally i have written a warning message for users that they should not use the back button but users seem to ignore this message and get into problem because the two pages have different roles and role of user is dynamically cahnged when the user goes from first apge to second one and on use of back button the user is not accepted because of different role.
Kinldy help me
Many thanks for your help