0

I am using CreateUserWizard Control with membership provider in asp.net 4.0.

In this case user name is stored in 'user name' field in aspnet_Users table.

I want to save 'user name' field in email field of aspnet_Membership table (In my case username is also email); In other words I want to change mapping of these fields.

How can I do this?

Note: My Problem is how to change mapping. Above is the only example

Brian Tompsett - 汤莱恩
  • 5,438
  • 68
  • 55
  • 126
Ali
  • 3,365
  • 10
  • 41
  • 62

1 Answers1

0

You can easily achive by calling CreateUser method instead of using CreateUserWizard.

<asp:TextBox ID="EmailTextBox" runat="Server" />
<asp:TextBox ID="PasswordTextBox" runat="Server" />
<asp:TextBox ID="PasswordQuestionTextBox" runat="Server" />
<asp:TextBox ID="PasswordAnswerTextBox" runat="Server" />

string username = EmailTextBox.text; // Same as email
string password = PasswordTextBox.text;
string email = EmailTextBox.text;
string passwordQuestion = PasswordQuestionTextBox.text;
string passwordAnswer = PasswordAnswerTextBox.text;
bool isApproved = true;

MembershipCreateStatus status;

MembershipUser membershipUser = System.Web.Security.Membership.CreateUser(username, password, email, passwordQuestion, passwordAnswer, isApproved, out status);

if (status != MembershipCreateStatus.Success)
   throw new Exception(status.ToString());
Win
  • 58,817
  • 13
  • 98
  • 174