Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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.

share|improve this question

3 Answers 3

up vote 2 down vote accepted

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.

share|improve this answer
2  
Thank you. lst.SetValueForUICulture(web.Locale, "My custom list 2"); worked. –  Gomiunik Mar 7 '12 at 6:40

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.

share|improve this answer
    
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 '12 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 '12 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 '12 at 21:06

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.

share|improve this answer

Your Answer

 
discard

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.