Refreshing the page causes resubmission the form

Joined
Apr 1, 2008
Messages
3
Reaction score
0
Using ASP.net 1.1 and Visual Studio 2003.

I have created a form....simple form with firstname, lastname, address, state etc. On Submit its supposed to create a userid n password. It uses static password. It checks the database to see if the userid firstname initial and lastname combination exists in database. If it does not exist, it adds the data to database and sends an email else it creates a new userid...submits the data in db and sends an email. I have a label on the same form to display the thank you message by making the form invisible. For some reasons, if I refresh the page, it resubmits the data and sends an email. How can I avoid that?

AutoPostBack is set to False for all the textboxes and button. AutoEventWireUp is set to False too. Here is some of my code.

private void InitializeComponent()
{
this.Button1.Click += new System.EventHandler(this.Button1_Click);
}

protected void Button1_Click(object sender, System.EventArgs e)
{
string strErrMsg = null;
string Message = null;
int newuserinserted = -1;
if (Page.IsValid) //Determine if the form entries were valid
{
bool useridexists = true;
int i = 0;
do
{
useridexists = CheckIfUserIDExists(); //find out if the user id exists
if (useridexists == true) //if the user id exists create a new user id
{
UserID = FirstName.Text.Substring(1,1) + LastName.Text + i++;
}
}
while (useridexists == true);

Thanks in advance!
 
Last edited:
Joined
Apr 1, 2008
Messages
3
Reaction score
0
By setting SmartNavigation=True....in IE it takes me back to the form once the thank you message is displayed. However, in Firefox, it asks if I would like to POSTDATA etc. which I don't want the user to determine.
 
Last edited:

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

Staff online

Members online

Forum statistics

Threads
473,755
Messages
2,569,534
Members
45,008
Latest member
Rahul737

Latest Threads

Top