I thought I could add an else condition to this if statement for when the username already existed and display an error message on screen - below the username field within the user control.
So far this hasn't worked.
Because I don't fully understand .net Membership can anyone advise if this is totally off-course and there is a better way to handle it ?
switch (e.CreateUserError) { case MembershipCreateStatus.DuplicateUserName: Label1.Text = "Username already exists. Please enter a different user name."; break;
case MembershipCreateStatus.DuplicateEmail: Label1.Text = "A username for that e-mail address already exists. Please enter a different e-mail address."; break;
case MembershipCreateStatus.InvalidPassword: Label1.Text = "The password provided is invalid. Please enter a valid password value."; break;
My post exposes my limited .net knowledge but it is a wicked feeling when you get something to work - albeit with excellent help from others. Sooo much to learn, sooo little time!
For others who may find this post the other thing to do was addthe OnCreateUserError="whatever you called the method" part to the CreateUserWizard tag as per below.
Membership Provider - Alert User To Existing Username
I have been working through Mike Taylors blog postings on creating / authenticating new members before activating them.
I have the users being created OK, but I have been doing some testing for duplicate usernames.
In the code behind there is the following:
I thought I could add an else condition to this if statement for when the username already existed and display an error message on screen - below the username field within the user control.
So far this hasn't worked.
Because I don't fully understand .net Membership can anyone advise if this is totally off-course and there is a better way to handle it ?
Thanks
Nigel
http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.createuserwizard.oncreateduser.aspx.
"Raises the CreatedUser event after the membership provider creates the user account."
> When you enter the CreatedUser method, the user has already been created, so user will never be null.
Handle the OnCreateUserError event instead:
http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.createuserwizard.oncreateusererror.aspx
This method returns a CreateUserErrorEventArgs object that holds the reason why user creation failed:
http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.createusererroreventargs.aspx
Hi Thomas
Wicked - thank you so much for your response.
My post exposes my limited .net knowledge but it is a wicked feeling when you get something to work - albeit with excellent help from others. Sooo much to learn, sooo little time!
For others who may find this post the other thing to do was addthe OnCreateUserError="whatever you called the method" part to the CreateUserWizard tag as per below.
Thanks again Thomas - an awsome start to my day.
Nigel
is working on a reply...