How can I prevent a second (or third or fourth) post into a database by
someone clicking the refresh button on their browser?
Basically, the user clicks a button called "New Log", which makes most
of the form within a <div runat="server"to go invisible and another
<divgo visible. This includes a text box and a save button. They type
text into the textbox and click save, which executes a stored procedure
that does the insert into an SQL database. Then that <divgoes
invisible and the original <divgoes visible. This all works fine but
if they hit the refresh button, another, exact post is supplied (with a
new time stamp since I also insert Now().
I tried this:
If txtNewLog.Text = "" Then
Else
objConnection.Open()
strNameUsers = objCommandUsers.ExecuteScalar()
objName.Value = strNameUsers
objCommand.ExecuteNonQuery()
objConnection.Close()
txtNewLog.Text = vbNullString
divPost.Visible = False
PopulateList("")
divNotes.Visible = True
txtNewLog.Text = ""
End If
Note that I try to clear the contents of the text box after the insert
is complete. I was hoping that if they hit refresh, the insert wouldn't
take place with this coding, but it does.
TIA,
Jim