Showing posts with label user information list. Show all posts
Showing posts with label user information list. Show all posts

Friday, 13 April 2012

Update the user information list in SharePoint at User Profile C#

SPSite spsite = SPContext.Current.Site;
SPWeb spweb = spsite.OpenWeb();
SPList splist = spweb.SiteUserInfoList;
SPListItem userInfo = splist.Items.GetItemById(SPContext.Current.Web.CurrentUser.ID);
try{
Msg.Text = " ";
if ((txtFirstName.Text != "") || (txtLastName.Text != ""))
{
userInfo["Title"] = txtFirstName.Text + " " + txtLastName.Text;
}
if (txtEmail.Text != "")
{
userInfo["Work e-mail"] = txtEmail.Text;
}
if (txtFirstName.Text != "")
{
userInfo["First name"] = txtFirstName.Text;
}
if (txtLastName.Text != "")
{
userInfo["Last name"] = txtLastName.Text;
}
if (txtMobilePhone.Text != "")
{
userInfo["Mobile phone"] = txtMobilePhone.Text;
}
if (txtWorkPhone.Text != "")
{
userInfo["Work phone"] = txtWorkPhone.Text;
}
if (txtUsername.Text != "")
{
userInfo["User name"] = txtUsername.Text;
}
Msg.Text += "Profile Details are updated";
userInfo.Update();
}
catch{
Msg.Text = "Profile Details are not updated";
}