i am using create user wizard to create new users. i don't want to allow enter the which has been already registred, i use this code for restricting the user to enter the duplicate email but it's not working .
private bool UserExists(string usernameEmail)
{
if (Membership.FindUsersByEmail(usernameEmail) != null)
{
return true;
}
return false;
}
protected void RegisterUser_NextButtonClick(object sender, WizardNavigationEventArgs e)
{
if (e.CurrentStepIndex == 0)
{
if (RegisterUser.Email.Trim() == "" || UserExists(RegisterUser.Email))
{
lblmsg.Text = "This Email Is already Exist ! Please try Another Email";
lblmsg.ForeColor = Color.Green;
e.Cancel = true;
}
else
{
e.Cancel = false;
}
}
}here lblmsg is label for displaying the error message and RegisterUser is ID of CreateUserWizard.
Nermin HuskicPosted Aug 20, 2013, 6:50 PM