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!
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: