-2

Possible Duplicate:
Disable browser's back button

I have a log in page

<div style="border:1px red;margin:150px 0px 0px 0px;text-align:center;">
UserName :<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox><br />
Password &nbsp:<asp:TextBox ID="txtpass" runat="server"></asp:TextBox><br />
asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Signin" /><br />
asp:Label ID="lblmsg" runat="server"></asp:Label>
/div>

I want to disable back button o this page using ASP.NET.

Community
  • 1
  • 1
  • 3
    I think you will find two things: 1) disabling the back button is not easily done, and 2) it is generally considered a *very bad* idea to disable expected behavior in the web browser. – Fredrik Mörk Jun 14 '11 at 08:55

2 Answers2

0

You can't do this in ASP.NET.

You may be able to achieve similar results, either by forcing the browser to navigate forward

javascript:window.history.forward(1);

or by including your login page in a frameset and forcing the parent frame to reload the login page.

<frameset onUnload="location.replace(self.location)">
Connell
  • 13,925
  • 11
  • 59
  • 92
-1

if you want javascript code then try this

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

cheers

Muhammad Akhtar
  • 51,913
  • 37
  • 138
  • 191
  • 1
    With this code you set a very bad load to the browser to call with out breath this function. This can cache a lot of problems to your user and make you page behave slow. – Aristos Jun 14 '11 at 10:09
  • @Aristos i dont think so –  Jun 14 '11 at 12:28
  • @ranjenanil the setTimeout creates a time, a new thread, that is call again and again the same function. a waist of resource. There are other methods to solve the issue of the re-post the data. – Aristos Jun 14 '11 at 14:39