Message to user when email not unique?
-
Hi I am using Visual Web Developer 2010 Express (with C# as code-behind) to develop a website. I have created a custom MembershipProvider and I have specified that in the web.config that
requiresUniqueEmail="true"
. In theCreateUser()
method I check whether the email that the new user has entered is unique and the code works. How do I then display a message to the user in theCreateUserWizard
if the email he has entered is not unique? I thought I could reference theCreateUserWizard
in theCreateUser()
method, but the following does not work:Label labelDuplicateEmail = (Label)CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("LabelDuplicateEmail");
labelDuplicateEmail.Text = "Email already exists in the database.";All help will be appreciated. Kobus
-
Hi I am using Visual Web Developer 2010 Express (with C# as code-behind) to develop a website. I have created a custom MembershipProvider and I have specified that in the web.config that
requiresUniqueEmail="true"
. In theCreateUser()
method I check whether the email that the new user has entered is unique and the code works. How do I then display a message to the user in theCreateUserWizard
if the email he has entered is not unique? I thought I could reference theCreateUserWizard
in theCreateUser()
method, but the following does not work:Label labelDuplicateEmail = (Label)CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("LabelDuplicateEmail");
labelDuplicateEmail.Text = "Email already exists in the database.";All help will be appreciated. Kobus
Hi I have managed to figure it out. I am using the
CreateUserError
event of theCreateUserWizard
.protected void RegisterUser_CreateUserError(object sender, CreateUserErrorEventArgs e)
{
Label labelDuplicateEmail = (Label)RegisterUser.CreateUserStep.ContentTemplateContainer.FindControl("LabelDuplicateEmail");
labelDuplicateEmail.Text = string.Empty;if (e.CreateUserError == System.Web.Security.MembershipCreateStatus.DuplicateEmail) { labelDuplicateEmail.Text = "Email address already exists in the database."; }
}
Kobus