G
Guest
I have this block of code below, but when ran it only creates the member it
doesnt fill in his profile data. Is there something I am missing? Please let
me know what I can do, just trying to progamatically create a member and fill
in his profile information. Thanks in advance.
protected void btnCreateuser_Click(object sender, EventArgs e)
{
// Store username for use
string strNewUsername = tbUserName.Text;
MembershipCreateStatus mcs = new MembershipCreateStatus();
// Create User Account
Membership.CreateUser(tbUserName.Text, tbPassword.Text,
tbEmail.Text, "What year was this application built?", "2006", true, out mcs);
Roles.AddUserToRole(strNewUsername, "user");
lblStatus.Text = mcs.ToString();
// Acces & fill new members profile with information
MembershipUser muNewUser = Membership.GetUser(strNewUsername);
ProfileCommon pcNewUser =
(ProfileCommon)ProfileBase.Create(muNewUser.UserName, true);
pcNewUser.Address1 = tbAddress.Text;
pcNewUser.Address2 = tbAddress2.Text;
pcNewUser.City = tbCity.Text;
pcNewUser.Name = tbName.Text;
pcNewUser.PhoneCell = tbCellPhone.Text;
pcNewUser.PhoneHome = tbHomePhone.Text;
pcNewUser.PhoneOffice = tbOfficePhone.Text;
pcNewUser.SponsorCode = Profile.UserName;
pcNewUser.SponsorCodeLevel2 = Profile.SponsorCode;
pcNewUser.State = tbState.Text;
pcNewUser.Zip = Int32.Parse(tbZip.Text);
}
doesnt fill in his profile data. Is there something I am missing? Please let
me know what I can do, just trying to progamatically create a member and fill
in his profile information. Thanks in advance.
protected void btnCreateuser_Click(object sender, EventArgs e)
{
// Store username for use
string strNewUsername = tbUserName.Text;
MembershipCreateStatus mcs = new MembershipCreateStatus();
// Create User Account
Membership.CreateUser(tbUserName.Text, tbPassword.Text,
tbEmail.Text, "What year was this application built?", "2006", true, out mcs);
Roles.AddUserToRole(strNewUsername, "user");
lblStatus.Text = mcs.ToString();
// Acces & fill new members profile with information
MembershipUser muNewUser = Membership.GetUser(strNewUsername);
ProfileCommon pcNewUser =
(ProfileCommon)ProfileBase.Create(muNewUser.UserName, true);
pcNewUser.Address1 = tbAddress.Text;
pcNewUser.Address2 = tbAddress2.Text;
pcNewUser.City = tbCity.Text;
pcNewUser.Name = tbName.Text;
pcNewUser.PhoneCell = tbCellPhone.Text;
pcNewUser.PhoneHome = tbHomePhone.Text;
pcNewUser.PhoneOffice = tbOfficePhone.Text;
pcNewUser.SponsorCode = Profile.UserName;
pcNewUser.SponsorCodeLevel2 = Profile.SponsorCode;
pcNewUser.State = tbState.Text;
pcNewUser.Zip = Int32.Parse(tbZip.Text);
}