473,583 Members | 2,858 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Refreshing without resubmitting

When form data is submitted to an ASP page using the POST method, it is not
visible in the URL, but it is still resubmitted if the user clicks the
Refresh button. This can cause statistical data to be accidentally submitted
multiple times, making the results incorrect. I would like like the user to
be able to click the Refresh button without resubmitting the form data. Is
there some way to "erase" the form data after it is used so that the Refresh
button does not resubmit it? Any help would be appreciated. Thanks.
--
Nathan Sokalski
nj********@hotm ail.com
www.nathansokalski.com
Jul 19 '05 #1
4 2440
Hi Nathan

I don't know whether this is the simplest solution but it should work.
Submit a time stamp with your data that you serve with the form in a
hidden field. Store the time stamp with the first submission, perhaps in
the cache with a shortish life time, and then don't act on subsequently
submitted data if the time stamp is the present in your chosen store.
Maybe you could derive a class from the Page class that encapsulates
that functionality and use it as the base for all of your pages to
prevent this behaviour.

Hope this helps
Graham

Nathan Sokalski wrote:
When form data is submitted to an ASP page using the POST method, it is not
visible in the URL, but it is still resubmitted if the user clicks the
Refresh button. This can cause statistical data to be accidentally submitted
multiple times, making the results incorrect. I would like like the user to
be able to click the Refresh button without resubmitting the form data. Is
there some way to "erase" the form data after it is used so that the Refresh
button does not resubmit it? Any help would be appreciated. Thanks.

Jul 19 '05 #2
"Nathan Sokalski" <nj********@hot mail.com> wrote in message news:<us******* *******@tk2msft ngp13.phx.gbl>. ..
When form data is submitted to an ASP page using the POST method, it is not
visible in the URL, but it is still resubmitted if the user clicks the
Refresh button. This can cause statistical data to be accidentally submitted
multiple times, making the results incorrect. I would like like the user to
be able to click the Refresh button without resubmitting the form data. Is
there some way to "erase" the form data after it is used so that the Refresh
button does not resubmit it? Any help would be appreciated. Thanks.


One workaround is to have the page which accept the form submission do
it's processing, then redirect to the page which displays the data.
The page which displays the data should not have any form data
submitted to it, nor does it process any data.
Jul 19 '05 #3

"Nathan Sokalski" <nj********@hot mail.com> wrote in message
news:us******** ******@tk2msftn gp13.phx.gbl...
When form data is submitted to an ASP page using the POST method, it is not visible in the URL, but it is still resubmitted if the user clicks the
Refresh button. This can cause statistical data to be accidentally submitted multiple times, making the results incorrect. I would like like the user to be able to click the Refresh button without resubmitting the form data. Is
there some way to "erase" the form data after it is used so that the Refresh button does not resubmit it? Any help would be appreciated. Thanks.
--
Nathan Sokalski
nj********@hotm ail.com
www.nathansokalski.com


Nathan --

Not knowing exactly how your code is written, I can only give you some
generic suggestions.

* In the server-side script, you can check
request.serverv ariables("REQUE ST_METHOD") to determine if it's a POST. If
so, execute the processing to perform the computations, otherwise, only send
the results. Example:

select case lcase(request.s ervervariables( "REQUEST_METHOD "))
case "post"
IsPostback = True 'a boolean to keep track of whether it's post
or get
' pull the inputs from the form and do the calculations
' ....
' store the results in a session variable or database you can
send down
case "get"
IsPostback = False
' retrieve the saved results and send them down
case else
' probably a spider crawling so deal with dismissing it
end select

* If you use the preceding approach, you may want to beef it up some by
adding a test in the case "post" to make sure your submit button was used to
submit perform the submit.

* Depending on the size and nature of the results, you can store them to a
scripting.dicti onary object (for simple label-value pairs) and stash it in
the session object, or a database or xml file and stash the retrieval string
in the session. Use a separate function you can call from the page
generation code or in the <body> to return the container and generate the
output HTML as you traverse it, or return fully formatted HTML.

<% option explicit %>
<%
response.buffer = true
dim IsPostback, nAmt, nIntRate, nYears
IsPostback = False
nAmt = 0
nIntRate = 0
nYears = 0
with request
if lcase(.serverva riables("REQUES T_METHOD")) = "post" then
IsPostback = True
nAmt = clng(.form("Amo unt"))
nIntRate = clng(.form("Int erest"))
nYears = clng(.form("Yea rs"))
If CalcResults(nAm t, nIntRate, nYears) Then
' deal with everything OK
Else
' deal with error
End If
end if
end with

Function CalcResults(byv al Amount, byval IntRate, byval Years)
dim blnRetVal, cn, strSQL, i, PmtAmt
blnRetVal = True
' check that the numbers are reasonable
' if not, blnRetVal = False and Exit Function

' open database connection
set cn = createobject("A DODB.Connection ")
cn.open 'yaddayadda
strSQL = "INSERT INTO results_table " & _
" (whos_asking, field1, field2) VALUES ("
for i = 1 to Years
' compute the loan payment for each year
PmtAmt = ...
' save the results
cn.execute strSQL & session("ThisUs erID") & _
", " & i & ", " & PmtAmt & ")"
' error trapping would set blnRetVal = False
next
cn.close
set cn = nothing
CalcResults = blnRetVal
End Function

Sub RenderOutputAsT able
' example: write a recordset to an HTML table
' assumes nothing will go wrong, always have error handling
dim cn, strSQL, rsResults
strSQL = "SELECT field1, field2 FROM results_table " & _
" WHERE whos_asking = " & session("ThisUs erID")
set cn = createobject("A DODB.Connection ")
' prep and open the connection
cn.open 'yaddayadda
with rsResults
.cursortype = adOpenStatic
.locktype = adOpenForwardOn ly
.activeconnecti on = cn
.open strSQL
.activeconnecti on = nothing
cn.close
set cn = nothing
response.write "<table><tr><td >Field_1</td>" & _
"<td>Field_ 2</td></tr>"
do until .EOF
response.write "<tr><td>" & .fields(0) & "</td>" & _
"<td>" & .fields(1) & "</td></tr>" & vbCrLf
.movenext
loop
response.write "</table>" & vbCrLf
.close
end with
set rsResult = nothing
End Sub
%>
<html>
<body>
<p>surroundin g html</p>
<form name="MyForm" method="POST">
Amount: <input type="text" name="Amount" value="<%=nAmt% >">
Int.%: <input type="text" name="Interest" value="<%=nIntR ate%>">
Years: <input type="text" name="Years" value="<%=nYear s%>">
<% if IsPostback then %>
<p>Results for <%=session("Thi sUserID")%><br>
(<%=nAmt%> for <%=nYears%> at <%=nIntRate%>%) </p>
<% RenderOutputAsT able %>
<p align="center">
<input type="submit" name="SubmitBut ton" value="Submit">
</p>
</form>
</body>
</html>

This is very over-simplified, but should give you an idea of how it would
work.

Mind you, this solution only works for classic ASP. You would have to use a
different strategy for ASP.NET as you can't intermix script and HTML. It
would be somewhat similar as ASP.NET has the postback check built-in, but
all your assignments would be server-side, and you have to be cognizant of
interaction with viewstate. There are some good articles on fiddling with
viewstate up on MSDN that can give some more guidance.

Alan
Jul 19 '05 #4
AAARRRRGGGGHHHH HHHHHHH!!!!! You posted in multiple newsgroups!!!!! !!
(Picking myself up from the floor)

I'll be posting a reply just to microsoft.publi c.inetserver.as p.general
Graham Pengelly wrote:
Hi Nathan

I don't know whether this is the simplest solution but it should work.
Submit a time stamp with your data that you serve with the form in a
hidden field. Store the time stamp with the first submission, perhaps in
the cache with a shortish life time, and then don't act on subsequently
submitted data if the time stamp is the present in your chosen store.
Maybe you could derive a class from the Page class that encapsulates
that functionality and use it as the base for all of your pages to
prevent this behaviour.

Hope this helps
Graham

Nathan Sokalski wrote:
When form data is submitted to an ASP page using the POST method, it
is not
visible in the URL, but it is still resubmitted if the user clicks the
Refresh button. This can cause statistical data to be accidentally
submitted
multiple times, making the results incorrect. I would like like the
user to
be able to click the Refresh button without resubmitting the form
data. Is
there some way to "erase" the form data after it is used so that the
Refresh
button does not resubmit it? Any help would be appreciated. Thanks.


Jul 19 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
3296
by: Scott Tilton | last post by:
I am having a terrible time getting this to work. I am hoping someone out there can help me with very specific code examples. I am trying to get the linked tables in my Access 97 database to be updated whenever the database opens. I need to have them updated based on an INI file that resides in the same directory as the current database. ...
2
2535
by: jdi | last post by:
Hello, I have a seemingly basic question about ASP.NET. I would like to create a page containing an image, which keeps swapping the url of the image source, without refreshing the entire page. So when the page first loads I'd like the image url to be "img1.gif"; then 20 seconds later "img2.gif"; then "img3.gif", and so on. All this should...
4
2010
by: Nathan Sokalski | last post by:
When form data is submitted to an ASP page using the POST method, it is not visible in the URL, but it is still resubmitted if the user clicks the Refresh button. This can cause statistical data to be accidentally submitted multiple times, making the results incorrect. I would like like the user to be able to click the Refresh button without...
5
3474
by: Jensen Bredal | last post by:
Hello, I need to display self refreshing information on a web page written with asp.net. I would image that the info would be displayed either as part of a user control or a web control. How can this be done? The information will come from a database and the displaying should loop throug a table in the database. Many thank in advance JB
2
2477
by: Ben | last post by:
Hi, One ASP.NET transactional page conducts a long transaction in a button click function. I want to display the transaction progress info in label control without refreshing page. It is because page refreshing will commit the transaction automatically. How to do it?
5
1685
by: chimambo | last post by:
Hi all, I have a problem with maintaining data without refreshing manually in my system. I have a system which carries data across several pages. But if a user wants to go back to the previous pages, he is asked to refresh at each stage, which is inconvenience. I want to be able to maintain the data without refreshing when a user presses a...
13
7437
by: honey99 | last post by:
Hi! I have to fix a problem in JSP.Actually,i have a JSP page say Ex1.jsp.In this Ex1.jsp i have an anchor tag which links into another JSP page i.e when i click on the link another pop-up window will open.My problem is the pop-up window and the parent window has same combobox.if i add data through html form in pop-up window(Ex2.jsp) it enters...
6
1943
by: shankari07 | last post by:
hi guys, I have a form in html which has the city drop down. when clicking the drop down a javascript is called and a file(test.txt) is created and the city is written into the file. Through php i want to open the same file(test.txt), fetch the values and display it in a text box without refreshing or reloading the form. Is it possible. ...
4
2542
by: thete | last post by:
how to avoid resubmitting the form in php
0
7888
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
8314
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7922
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
8185
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6571
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5689
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3811
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
2317
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1416
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.