I want to use the regular login system in an ASP.NET app, but I want to use the user's email address as their user name (as is common in many web sites.) However, there seems to be no property or attribute to allow me to do something like this; user name and email address always seem to be separate. Is it possible to do this or is some complex customization required? Thanks.
3 Answers
I'm assuming you're talking about the CreateUserWizard control.
In the designer, right click on the CreateUserWizard control and select "Customize Create User Step". This will allow you to delete the email field row. I'd also recommend adding a RegularExpressionValidator to validate the email format for the user name.
To copy the user name to the email address, handle the CreatingUser event and do it there:
protected void CreateUserWizard1_CreatingUser( object sender, LoginCancelEventArgs e )
{
CreateUserWizard1.Email = CreateUserWizard1.UserName;
}
2 Comments
Having done this same thing for multiple web sites, it ended up being easiest to just use the email address for the UserName and the EmailAddress fields, rather than trying to change the Membership API to use the existing EmailAddress field over UserName.
2 Comments
You have write your custom membership provider for that. For that you have inherit the membership provider class and need to create your own membership provider.
Here are some good links for you..
http://www.15seconds.com/issue/050216.htm
Here is link for good discussions.