0

I am trying to create a custom web part which shows the current users photo and his name.

Also i am giving two buttons one for adding an image and another for setting it to default image or removing the image.

The functionality for adding a profile image is working fine but removing or setting it to a default image is pending. I need help

1

I have copied the default image in SharePoint and using the below code to load the default image:

 imgUserProfilePagePicture.ImageUrl = SPContext.Current.Site.Url + "/_layouts/15/images/PersonPlaceholder.200x150x32.png";
0

I used the following code:

SPSite site = SPContext.Current.Site;
UserProfileManager userProfileManager = new UserProfileManager(SPServiceContext.GetContext(site));
// accountName is Active Directory account
UserProfile userProfile = userProfileManager.GetUserProfile(accountName);
// PictureUrl is the property you need to set.. set it to Empty string..
userProfile["PictureUrl"].Value = string.Empty;
// commit the change
userProfile.Commit();

Added this code to the onclick of an image link. When i click on this it removes the image and set it to the default image

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.