Re: Refresh questions

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance




"Mr Newbie" <here@xxxxxxx> wrote in message
news:%23ZSECiSHGHA.344@xxxxxxxxxxxxxxxxxxxxxxx
: Before someone flames me, I know this is the VB.NET groups, nonetheless,
: the asp.net guys seems to have almost disapeared from the aspnet groups
: so I thought I would ask this here.
:
: I have a problem with an aspx web form in that if I refresh, it simply
: resubmits the form and causes multiple submissions, in this case the form
: is one which adds records to the database and refreshing a previously
: submitted item repeats each time the refresh is clicked.
:
: Does anyone have a suggestion on how I can get around this ?
:
: Thanks
:
: --
: Best Regards
:
: The Inimitable Mr Newbie º¿º


I had a problem like that once. What I ended up doing was creating a field
in my database that stored a submission ID and checking it when the page is
submitted. When the page was initially loaded (not the post back), a unique
value (including date time stamp in this case) was generated and included as
a hidden field in the form.


When the form was submitted I'd check that value to see if it existed in the
database. If it didn't, I allowed the submission to be inserted into the
database and I returned a response method appropriate the specifics of this
submission. Part of the insert action was to add this value into the record.


If the page was resubmitted, the same value would exist in the database when
the page was processed. In this case, I did not attempt to update the
database a 2nd time with the same values. I didn't object to the user or
anything but instead simply returned the same response that I would have if
I accepted the values.


There is at least one down side to this. If the user actually refreshes the
page, a new ID value would be generated and if submitted, the values would
be inserted twice because the system would think of this as a unique
submission. To get around that, I actually created the ID value two pages
back and passed it forward in hidden fields. Each page would POST to the
next in a cascading fashion. If the page in question was accessed directly
(or for any other reason the ID field wasn't present in the Request.Form
object when the page initially loaded), I'd redirect the user to the home
page and force them to start over. That way they couldn't jump into the
middle of the process and bypass this check.


This way, the user would have to back up two pages and refresh in order to
generate a new ID value. What actually happens is that the users start over
with a new process which was the intention all along (the refresh/resubmits
were never deliberate, rather they were the result of users being impatient
and not understanding what was happening).


I was never fully happy with the process (it just seemed somehow awfully
contrived to me), but it works. We eliminated duplicate submissions in our
system and the users seem no worse for the wear. This doesn't seem to be
exactly what you are talking about, but perhaps a variation of this approach
may serve your purposes.


Ralf
--
--
----------------------------------------------------------
* ^~^ ^~^ *
* _ {~ ~} {~ ~} _ *
* /_``>*< >*<''_\ *
* (\--_)++) (++(_--/) *
----------------------------------------------------------
There are no advanced students in Aikido - there are only
competent beginners. There are no advanced techniques -
only the correct application of basic principles.



.



Relevant Pages

  • Re: Refresh questions
    ... submitted item repeats each time the refresh is clicked. ... > in my database that stored a submission ID and checking it when the page ... > a hidden field in the form. ... I allowed the submission to be inserted into the ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Refresh questions
    ... Preventing Duplicate Record Insertion on Page Refresh ... > in my database that stored a submission ID and checking it when the page ... I allowed the submission to be inserted into the ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Duplicate records added from post forms, easy solutions?
    ... When a user submits / posts data my php script Inserts data into my ... database. ... If they refresh the script or click back and click submit again I get ... Or do I need to create a hidden field which contains some sort of ...
    (comp.lang.php)
  • Re: Inlavid Operation ereror when refresh table link
    ... I also use it to refresh my links. ... Dim strTblName As String, strConn As String ... Dim db As DataBase, rs As Recordset, tbl As TableDef ...
    (comp.databases.ms-access)
  • Re: multi-user combo-box refresh not working
    ... Nobody said that going to a split database will cure this particular ... Splitting the database, and giving ... On which machine is the refresh not working? ... refresh whichever control or form this is affecting on a regular basis. ...
    (microsoft.public.access.modulesdaovba)