ASPX templates
Version 5.x > ASPX templates > user profile update vai API View modes: 
User avatar
Member
Member
crsmith-epri - 12/8/2012 10:32:38 AM
   
user profile update vai API
Hi All,

I'm trying to add a page to allow the user to update their information. I basically stripped down the registration webpart example and grabbed the user information in SetupControl() and placed in the page text fields.

Then, under btnOK_Click() I create a userInfo from the current user and assign the values from the page text fields. Finally, I perform a UserInfoProvider.SetUserInfo(), but it does not update the fields in the database. Here is a snippet below, I followed the exam in the documentation, so I'm at a lost of why it does not update the fields.

Thanks,
Craig.
v5.5R2

 protected void btnOK_Click(object sender, EventArgs e)
{
#region "User properties"

UserInfo ui = CMSContext.CurrentUser;
if (ui != null)
{
ui.Email = txtEmail.Text.Trim();
ui.FirstName = txtFirstName.Text.Trim();
ui.FullName = txtFirstName.Text.Trim() + " " + txtLastName.Text.Trim();
ui.LastName = txtLastName.Text.Trim();
// PDI custom fields added in CMS.user table...
ui.SetCompanyName(txtCompany.Text);
ui.SetAddress1(txtAddress1.Text);
ui.SetAddress2(txtAddress2.Text);
ui.SetCity(txtCity.Text);
ui.SetState(txtState.Text);
ui.SetCountry(txtCountry.Text);
ui.SetZipcode(txtZipcode.Text);
ui.SetValue("Phone", txtPhone.Text.Trim());
ui.SetValue("Fax", txtFax.Text.Trim());
if (txtMembership.SelectedValue.Trim() == "")
ui.SetValue("Membership", "None");
else
ui.SetValue("Membership", txtMembership.SelectedValue.Trim());

// Store to DB
UserInfoProvider.SetUserInfo(ui);
}
else
Response.Redirect("/Error.aspx");

#endregion

lblError.Visible = false;
Response.Redirect("/Home.aspx");
}

#endregion

protected void btnSkip_Click(object sender, EventArgs e)
{
Response.Redirect("/Home.aspx");
}
}

User avatar
Kentico Customer Success
Kentico Customer Success
kentico_martind2 - 12/10/2012 5:50:10 AM
   
RE:user profile update vai API
Hi Craig,

Have you tried to debug your code if your method is event reached? The code itself looks fine, please try to run in the debug mode and maybe you will find out where the issue is.

Best regards,
Martin Danko