Kaustav's suggestion will work, but it will cause an extra trip to the
server. You could also use the Page's RegisterStartupScript 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.Redirect), 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*****@discussions.microsoft.com> wrote in message
news:86**********************************@microsof t.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 "lblPostback" 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.Text = ""
End If
Button Submit Event:
On the button submit event, after all the processing has been done, place
the following code snippet-
lblPostback.Text = "<script>javascript:__doPostBack('','');</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