Reputation: 13
I am new in ASP.
I have a submit.asp page => thankyou.asp page. when pressing browser refresh, it reload and re-send a new data submissions. It caused me getting a lot of multiple submission.
I'm trying to add this in, its work , but little problem still when pressing the leaving button , thankyou.asp page refresh and loading a fresh new entry.
<script type="text/javascript">
window.onbeforeunload = function() {
return "You are leaving now! See you again !";
}
</script>
I'm asking for help on how to redirect to another page when browser refresh.
Thanks!
Michael
Upvotes: 1
Views: 2778
Reputation: 2729
As Faisal says, redirecting back to the same page will prevent the form resubmitting on refresh.
This can be done in the following way:
<%
If Request.Form("submit") <> "" Then
'form processing goes here
Response.Redirect "thankyou.asp"
End If
%>
Where "submit"
in Request.Form("submit")
relates to the name
attribute of
<input type="submit" name="submit" value="Submit!" />
in submit.asp
Upvotes: 3
Reputation: 18978
Change it so if the user submits, you process the form, then redirect back to the page itself. This way when the user refreshes, it won't submit the form again
Upvotes: 4