Back Button Click Issue

Hi guys, I inserted a record in my database and if it is successful, then, it will automatically redirected on a certain page. However, when I click on the BACK button of the browser, it will bring back of course the previous page and at the same time, the data that I encoded still appear. How am be able my page that if in case my users click on the Back button of the browser it will redirect on a certain page or if not, the entries will not appear.

I think I understand your question. One way to handle it is, when the page successfully sent the data to the database, you can add a value to the session, like so:


Session["DataWasSuccessful"] = True;
Response.Redirect("page2.aspx");

Then, if you hit the BACK button, you can test if the data was inserted:


if(Session["DataWasSuccessful"] != null)
{
//Clear controls
}
else
{
//show values in controls
}

thanks

That is not going to work unless the user can only do this once. As if they browse back to this page at a later stage, the session might still exist. So just take note of that

So, how can I handle this kind of situation NightStalker-DNS?

Very tough problem to solve. Only thing I can think of off hand would be to create a cookie on insert which expires after 5min or on the main page load remove the cookie. Then on insert check if the cookie exists or not. But this could have its own issues, but I cnt think it throught correctly now, its been a long day. lol