Friday, February 09, 2007

Make a page refresh after a form submit


Guess what happens, if you insert new records in a datatable on a button click, then press F5, or the refresh button of the browser?! The same record is going to be inserted again. I found this very annoying.
A simple solution: redirect to the same page at the end of the button click event handler.
private void SaveClicked(object sender, EventArgs e)
{
// insert a record somewhere in a datatable
Response.Redirect(itself); // itself being the URL of the current page
}

1 comment:

Unknown said...

Advertising is the genie which is transforming America into a place of comfort, luxury and ease for millions. See the link below for more info.


#genie
www.ufgop.org