473,403 Members | 2,270 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,403 software developers and data experts.

Refresh questions

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 º¿º
Jan 19 '06 #1
9 1508
Add this to your page_load event

If Not Page.IsPostBack Then
'The code currently in your Load event
End If

Jan 19 '06 #2
No that wont help because this form can postback several times, it is the
false submission which I am after, in other words the code behind the
submit button re-runs on refresh

--
Best Regards

The Inimitable Mr Newbie º¿º
<cb****@duclaw.com> wrote in message
news:11*********************@z14g2000cwz.googlegro ups.com...
Add this to your page_load event

If Not Page.IsPostBack Then
'The code currently in your Load event
End If

Jan 19 '06 #3
Well, I guess it really depends on what the code does. You could store
something in View or Session state that gets checked on each submit.
Depends how you feel about Session objects. Cant help much more
without seeing the code or knowing what the code does.

Jan 19 '06 #4

"Mr Newbie" <he**@now.com> wrote in message
news:%2***************@TK2MSFTNGP11.phx.gbl...
: 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.

Jan 19 '06 #5
Excellent reply Ralf. I think I need to think this throught after what you
have suggested.

Thanks

--
Best Regards

The Inimitable Mr Newbie º¿º
"_AnonCoward" <ab****@uvwxyz.com> wrote in message
news:Si******************@southeast.rr.com...

"Mr Newbie" <he**@now.com> wrote in message
news:%2***************@TK2MSFTNGP11.phx.gbl...
: 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.

Jan 19 '06 #6
here's an article dedicated for the subject

Preventing Duplicate Record Insertion on Page Refresh
http://aspalliance.com/687
--
Best Regards

The Inimitable Mr Newbie º¿º
"_AnonCoward" <ab****@uvwxyz.com> wrote in message
news:Si******************@southeast.rr.com...

"Mr Newbie" <he**@now.com> wrote in message
news:%2***************@TK2MSFTNGP11.phx.gbl...
: 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.

Jan 19 '06 #7
Mr. Newbie,

From the previous messages I get the idea that you are using an autokey. Try
to avoid that. The nicest recordidentifier in a database is the GUID

http://www.vb-tips.com/default.aspx?...3-fee3733fcd6f

I hope this helps,

Cor
Jan 20 '06 #8
Question; Why is the submit button click event fired if a page is refreshed?
--
Dennis in Houston
"Cor Ligthert [MVP]" wrote:
Mr. Newbie,

From the previous messages I get the idea that you are using an autokey. Try
to avoid that. The nicest recordidentifier in a database is the GUID

http://www.vb-tips.com/default.aspx?...3-fee3733fcd6f

I hope this helps,

Cor

Jan 21 '06 #9
Because the client must repost the header which has is a POST. I think
explorer seems to go one step further and emulates the last post completely
even if you clear the headers on pre-render event.

--
Best Regards

The Inimitable Mr Newbie º¿º
"Dennis" <De****@discussions.microsoft.com> wrote in message
news:60**********************************@microsof t.com...
Question; Why is the submit button click event fired if a page is
refreshed?
--
Dennis in Houston
"Cor Ligthert [MVP]" wrote:
Mr. Newbie,

From the previous messages I get the idea that you are using an autokey.
Try
to avoid that. The nicest recordidentifier in a database is the GUID

http://www.vb-tips.com/default.aspx?...3-fee3733fcd6f

I hope this helps,

Cor

Jan 21 '06 #10

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

Similar topics

10
by: Conax | last post by:
Hi there, My boss is hoping that I can come up with a page that displays some information. The information will always be displayed on specific part of the page, with auto refresh. But he...
6
by: laura | last post by:
I'm doing a page which gathers some text in the form of a text box in a <form>. This text is saved to a text file, notices.txt and I want to be able to display the saved text on the page, as soon...
18
by: Brandon Bray [MSFT] | last post by:
Shortly, the Visual C++ Tools Refresh will be available on the MSDN Visual C++ devcenter. You will need to have installed the Visual Studio 2005 Beta first. <http://msdn.microsoft.com/visualc> I...
10
by: tasmisr | last post by:
This is an old problem,, but I never had it so bad like this before,, the events are refiring when clicking the Browser refresh button. In the Submit button in my webform, I capture the server side...
2
by: Jeronimo Bertran | last post by:
Hi, I have a page with a very data intensive grid which needs to be automatically refreshed constantly if a change is detected. In order to not refresh the complete page so often, I created an...
17
by: SamSpade | last post by:
picDocument is a picturebox When I do picDocument.Invalidate() the box paints. But if instead I do picDocument.Refresh() the box does not paint. What does Refresh do. I guessed it did an...
4
by: =?Utf-8?B?YmJkb2J1ZGR5?= | last post by:
I have a couple of questions, these are problems that I have experienced with IE 6 1. I have a label on a form, and sometimes when the form refreshes the label doesn't appear on the screen,...
0
Boxcar74
by: Boxcar74 | last post by:
Hi Everybody!!! I have an Issue. I have an Excel file that queries an Access db. I’m trying to have it so I don’t have to keep updating it manually everyday and save it to a network drive...
3
by: sake | last post by:
I feel like I'm asking a lot of questions lately, so first, just let me thank all of you who have been helping me. It's saved me a world of time. Anyway, I have a layout of two frames. On the side...
4
econVictim
by: econVictim | last post by:
i have a user profile oriented website where every page has a form in it. I want people to submit the form and cause a refresh... I also want the page to refresh if they hit the back button so...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...
0
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...
0
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...
0
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,...

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.