refresh cause insert to database :(

K

Krzysiek

Hello All,

I have really simple form that insert data from web controls to a DB after
submit is called. This works fine but after submit when u refresh the page,
this insert is fireed again..

i use ispostback clause however it doesn't prevent runnig a code after
refresh...

e.g

sub page_load()

'form controls..

if ispostback then

DB actions

end if

end sub


thx in advance!

Krzysiek
 
R

Robert Koritnik

The best way is to make some private bool property that uses ViewState. When
the page first loads (!IsPostBack) you set it to false. And when you commit
data to DB set it to true. Al subsequent postbacks should check for its TRUE
value preventind duplicate commit to DB.
 
R

Robert Koritnik

Or you can also redirect to some other page, when you commit. Or you can
also redirect to the same page so IsPostBack would again be false...
Whatever. Sometimes is best to display status report after DB C.R.U.D.
actions to inform user of successful actions.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,125
Messages
2,570,748
Members
47,301
Latest member
SusannaCgx

Latest Threads

Top