Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
Classic ASP Databases Discuss using ASP 3 to work with data in databases, including ASP Database Setup issues from the old P2P forum on this specific subtopic. See also the book forum Beginning ASP.NET Databases for questions specific to that book. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Databases section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old May 9th, 2005, 05:35 PM
Friend of Wrox
 
Join Date: Jul 2003
Location: , , .
Posts: 128
Thanks: 0
Thanked 0 Times in 0 Posts
Default Browser's BACK Button Problem

Hi All,

I have an ASP page where users submit a form. Once submited, a record will be created in a SQL database with firstname+lastname+time being the PRIMIARY Key. Here is the problem. Let say the user decided to make a change(after he clicked on the submit button). To do so, he click on the Browser's "BACK" button. Then he make his changes(WITHOUT doing a refresh first). After making the changes, he hit SUBMIT button. As you have guessed, the page get an error message: "Violation of PRIMARY KEY constraint." How can I fix this problem? I want to do something where when the user click on the back button, a message similar to: "This page has expired, please do a refresh...." Any other option is appreciated as well

Thank you.

Leon

  #2 (permalink)  
Old May 10th, 2005, 08:13 AM
Friend of Wrox
 
Join Date: Oct 2003
Location: Chennai, TamilNadu, India.
Posts: 326
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to Santhi Send a message via MSN to Santhi
Default

You can fix this by clearing the history when user clicks on the back button using javascript.


  #3 (permalink)  
Old May 11th, 2005, 09:47 AM
Friend of Wrox
 
Join Date: Jul 2003
Location: , , .
Posts: 128
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Santhi,

Thank you for the advice. Just how do I go about clearing the history with Javascript? Just a hint will be fine.

Thank you.

Leon

  #4 (permalink)  
Old May 12th, 2005, 01:16 AM
Friend of Wrox
 
Join Date: Oct 2003
Location: Chennai, TamilNadu, India.
Posts: 326
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to Santhi Send a message via MSN to Santhi
Default

You have to use location.replace(url) or history.go(1) to navigate when the user clicks on Back button in the browser.This way user wont be able to see the entered page.
This way we can clear the history making history object stores only one entry.

  #5 (permalink)  
Old May 13th, 2005, 12:35 AM
Authorized User
 
Join Date: Aug 2003
Location: , , India.
Posts: 52
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I don't think you can track the back button click because neither the
history.go() nor history.back() event is fired on clicking the browser back button.
One solution i prefer is as soon the registration is done successfully you set some session variable and check for this session variable on top of all pages. If it is already set that means the user has already registered and tried to come on the page using back button. You can redirect him to some error page on this.

Regards,
Vinay

  #6 (permalink)  
Old May 13th, 2005, 06:30 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: Bangalore, KA, India.
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

Leon,

I would say you add the

Code:
onload = "Javascript:history.go(1);"
in the
Code:
<body ...>
tag of the FORM page. This would not let him go back, when tried, would push him forward to the same page. And if at all he would like to make changes, he has to come from the beginning.

Hope that helps.
Cheers!



_________________________
- Vijay G
Strive for Perfection
  #7 (permalink)  
Old May 16th, 2005, 03:10 PM
Friend of Wrox
 
Join Date: Jul 2003
Location: , , .
Posts: 128
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thank you all VERY MUCH for your help, and especially Vijay. It works!!! :-)
Thanks again.

Leon



Similar Threads
Thread Thread Starter Forum Replies Last Post
Disabling browser's "X" button farhanzia HTML Code Clinic 4 March 23rd, 2005 01:19 PM
How to disable browser's refresh button ? sherbir Javascript 3 September 15th, 2004 11:42 PM
Disabling browser's window "X" button farhanzia Classic ASP Professional 1 July 9th, 2003 06:29 PM
Disabling browser's "X" button farhanzia Javascript 1 July 9th, 2003 10:04 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.