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! :)

1 Answer 1


You are missing:

  • Absolutely, it worked! :-D
    – Aidenn
    Jun 1, 2012 at 6:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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