SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to programatically update the title of some webparts. To do this, I am getting all the pages from the site, getting the webparts for each page, and first print out the current title, change it and then print it out again to verify the title was correctly changed. Nevertheless, if I afterwards check, I still see the old title for the webparts... What am I missing?

The code is as follows:

... getting the pages for the site...
SPFile ofile = page.File;

SPLimitedWebPartManager wpColl = ofile.GetLimitedWebPartManager(System.Web.UI.WebControls.WebParts.PersonalizationScope.User);
int cont = wpColl.WebParts.Count;

for (int i = 0; i < cont; i++)
    System.Web.UI.WebControls.WebParts.WebPart wp1 = wpColl.WebParts[i];
Console.WriteLine("        - Title : " + wp1.Title);

wp1.Title = "test" + i;

Console.WriteLine("        - New title: " + wp1.Title);


Thanks for any tips! :)

share|improve this question
up vote 5 down vote accepted

You are missing:

share|improve this answer
Absolutely, it worked! :-D – Aidenn Jun 1 '12 at 6:31

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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