1

If I use

using(SPSite site = new SPSite("http://somwewb"))
{
  using(SPWeb web = site.OpenWeb())
  {
    SPList lst = web.Lists["My custom list"];
    lst.Title = "My custom list 2";
    lst.Update();
  }
}

and I preview my changes in a browser, nothing happens. The same code tried on another server and there it was working. Both have december CU installed. Does anyone know what could be the reason for the code not to work on one server? I've also tried with web.AllowUnsafeUpdates = true;

Update: Standard update throught web interface works with no problem.

UPDATE AGAIN: This solves the problem: If the thread running is not in the same CultureInfo as the web language, it will not update properties.

So the solution is when you have the web open start immediately with the following line:

Thread.CurrentThread.CurrentUICulture = new CultureInfo((int)web.Language);

I found the solution here.

3 Answers 3

2

If you have a language pack applied and your site is not in english, try updating the SPList.TitleResource property, using SPUserResource.SetValueForUICulture.

Also, if you are looking at the quick launch or top navigation links, those get a copy of the value once set and might retain the old value even if you change the list's name.

1
  • 2
    Thank you. lst.SetValueForUICulture(web.Locale, "My custom list 2"); worked.
    – Gomiunik
    Mar 7, 2012 at 6:40
0

Try wrapping your whole code block in a RunWithElevatedPrivileges command

SPSecurity.RunWithElevatedPrivileges(delegate() { 
   ... your code here ...
});

if that doesn't work, look into whether or not Page Output Caching is enabled as that can cause the same results.

3
  • Thank you for your answer. I've also tried RunWithElevatedPrivileges, but still no change. I've also tried re-running the SharePoint Products and Technologies configuration wizzard. No luck. If I understand correctly Page Output Caching is part of the publishing feature? I'm not using publishing feature on the box where the bug arises.
    – Gomiunik
    Mar 7, 2012 at 0:00
  • Just out of curiosity, what is different between this server and the other one? Do the service accounts differ?
    – Dave Wise
    Mar 7, 2012 at 13:48
  • One (where it's working) is a development environment for SP Foundation on Win7, app pool configured with network service, other is Win2k8 with AD Service accounts. But I don't think this is the reason.
    – Gomiunik
    Mar 7, 2012 at 21:06
0

Can you try debugging the code from the server which is not working? May be there is an error happening in the code before even reaching the list.

See the ULS logs or put a try catch block or print some temp variable on the page after each line of code to see where it might be breaking.

Good Luck.

Your Answer

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

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