I have a web form that inserts a record into a DB. This function is called
from the button_click subroutine.
After the record is inserted, I show/hide some different panels and let the
page postback.
The problem is that if a person reloads this page after submitting, a new
record is inserted into the DB.
Short of doing an actual compare query prior to entering the new record, or
redirecting to a new page, is there a way to prevent this from happening?
-Darrel 5 2953
Hi Darrel,
one way to avoid this is to clear all values in the cache after postback.
You can use the Javascript doPostBack function for the same. Place a label
control "lblPostbac k" at the end of the page. Next place the following code
in the respective events as mentioned below:
Page Load Event:
If Page.IsPostback Then
lblPostback.Tex t = ""
End If
Button Submit Event:
On the button submit event, after all the processing has been done, place
the following code snippet-
lblPostback.Tex t = "<script>javasc ript:__doPostBa ck('','');</script>"
HTH.
Kaustav Neogy.
"Darrel" wrote: I have a web form that inserts a record into a DB. This function is called from the button_click subroutine.
After the record is inserted, I show/hide some different panels and let the page postback.
The problem is that if a person reloads this page after submitting, a new record is inserted into the DB.
Short of doing an actual compare query prior to entering the new record, or redirecting to a new page, is there a way to prevent this from happening?
-Darrel
Kaustav's suggestion will work, but it will cause an extra trip to the
server. You could also use the Page's RegisterStartup Script method to invoke
a Javascript method at the Page's load.
One thing you should ask yourself is, would it be possible to redirect the
user to a different page (using Response.Redire ct), and achieve the same
results? For example, if you have a Form that has a set of TextBoxs and a
button which will insert the data, you can simply redirect the user to the
same page, which will get rid of any PostBack issues (such as having the
non-user-friendly "The page cannot be refreshed..." confirm box IE has).
Perhaps you could use a QueryString that would tell the page to use
information from the newest submitted record. I'm not sure of your
situation.
Hope I could help,
Johann MacDonagh
"Kaustav" <Ka*****@discus sions.microsoft .com> wrote in message
news:86******** *************** ***********@mic rosoft.com... Hi Darrel,
one way to avoid this is to clear all values in the cache after postback. You can use the Javascript doPostBack function for the same. Place a label control "lblPostbac k" at the end of the page. Next place the following code in the respective events as mentioned below:
Page Load Event:
If Page.IsPostback Then lblPostback.Tex t = "" End If
Button Submit Event: On the button submit event, after all the processing has been done, place the following code snippet-
lblPostback.Tex t = "<script>javasc ript:__doPostBa ck('','');</script>"
HTH.
Kaustav Neogy.
"Darrel" wrote:
I have a web form that inserts a record into a DB. This function is called from the button_click subroutine.
After the record is inserted, I show/hide some different panels and let the page postback.
The problem is that if a person reloads this page after submitting, a new record is inserted into the DB.
Short of doing an actual compare query prior to entering the new record, or redirecting to a new page, is there a way to prevent this from happening?
-Darrel
> I'm not sure of your situation.
I have a page with two panels. One panel is the form. One panel is the
'success' confirmation.
On completion of a succesful submit, I hid the form panel and show the
success panel.
When a person reloads the page, though, it resubmits the data. I was
confused because the data is only submitted via the button_click
function...not the page_load function.
However, I think simply adding a flag on submit is the way to go...but yea,
it looks like a roundtrip to the server.
I suppose redirectly to another page is perhaps a better idea. However, I
have dozens of these submit/confirm combo pages so that may have to get put
off and added to the bottom of the to-do list.
-Darrel
Darrel wrote: I'm not sure of your situation. I have a page with two panels. One panel is the form. One panel is the 'success' confirmation.
On completion of a succesful submit, I hid the form panel and show the success panel.
When a person reloads the page, though, it resubmits the data. I was confused because the data is only submitted via the button_click function...not the page_load function.
"reload" means "execute the same action that originally gave you this page",
so the browser will act (submit the form) as if that button was pressed,
using the values that were previously on the form. So a resubmit of the
same data is correct (though unwanted :-) ) behaviour.
However, I think simply adding a flag on submit is the way to go...but yea, it looks like a roundtrip to the server.
But: it will use the *previous* values!
I suppose redirectly to another page is perhaps a better idea. However, I have dozens of these submit/confirm combo pages so that may have to get put off and added to the bottom of the to-do list.
-Darrel
> > However, I think simply adding a flag on submit is the way to go...but yea, it looks like a roundtrip to the server.
But: it will use the *previous* values!
Ah...duh. You're right. Hmm...crap...th is seems like something .net should
be able to handle for you ;o)
I guess it looks like a final page redirect and/or checking for duplicate
records in the DB are the only answer? (Though the javascript solution might
work...though I'd rather avoid javascript for checkig data integrity).
-Darrel This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: marx |
last post by:
I have a bit of a problem and any help would be much appreciated.
Problem: I have two dropdown list boxes with same data(all data
driven).
These are used for two separate entries.
For every entry you cannot choose the same value twice.
For example, I cannot choose for entry 1 the same
value in both selection boxes (gqCategory1Entry1 and
gqCategory2Entry1)
|
by: Drew |
last post by:
I have a permission tracking app that I am working on, and I have made the
insert page for it. I am having issues on how to prevent duplicates from
getting entered.
Currently the interface for the app has a mixture of select boxes, list
boxes and checkboxes. The form submits the page to processAIMR.asp and then
does the inserting. I am using a loop to insert a new record for each
checkbox checked or listbox entry selected.
My...
|
by: Randy |
last post by:
I am using Approach 9.8 and have set up a appointment database with
the following fields.
DATE, TYPEACTION, TIME, WORKER LASTNAME FIRSTNAME
I do not want my clerical staff to be able to key in a date if
DATE is the same, TYPEACTION=LEAVE, AND WORKER is the same.
I can use the Combine function and prevent data entry by using a
|
by: ColinWard |
last post by:
I am using the following code to validate that the person that is being
entered into the database does not already exist. However wnem I test it
by entering myself as a contact(I first checked that I was indeed NOT in
the database), the message still comes up saying that I am in the
database. what am I doing wrong?
Private Sub txtEmailName_AfterUpdate()
On Error GoTo Err_txtEmailName_AfterUpdate
>> If DLookup("EmailName", "Contacts",...
|
by: Manish |
last post by:
The topic is related to MySQL database.
Suppose a table "address" contains the following records
-------------------------------------------------------
| name | address | phone |
-------------------------------------------------------
| mr x | 8th lane | 124364 |
| mr x | 6th lane | 435783 |
| mrs x | 6th lane | 435783 |
| |
by: pcnorb |
last post by:
I have a form, pulling data from a Products table that has many fields
that do lookups to other tables. These are in a one-to-many
relationship to a pk in each of said tables.
I'd like to be able to compare the data on a BeforeUpdate event to be
sure that this data is not duplicated.
Here is the structure:
Products 8-1 Frames
|
by: chowdary |
last post by:
I am developing a PHP-mysql database. It is noted that when the
browser window is refreshed the data is inserted again in the
database. unfortunately there is no unique keys that I can use to
verify the existance of the data, so as to prevent the multiple
insertion.
|
by: rjshrader |
last post by:
I have a table (tblStatus) with three fields (CustomerID, StatusType
and StatusDate). I use an unbound form with three text boxes to enter
data into the table when a command button (cmdSave) is clicked.
CustomerID, StatusType are values that are manually entered by the
user; StatusDate is automatically filled with the current date that
the record is saved.
I would like to use code behind the cmdSave button to check the table
for...
|
by: AXESMI59 |
last post by:
have a project in which I am entering Serial Numbers and Date codes into a Combo box. Serial numbers are all different. However, they could each have the same Date Code. Each Serial Number has a corresponding Date Code which I then write to a table using VBA. When I try to enter a duplicate date code, it automatically finds the duplicate and will not allow me to add it again to that combo box. How do I configure that combo box so I can enter the...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
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 captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |