Well, the code for doing that is extremely simple, I found it on Microsoft's web page:
using(SPWeb oWebsite = SPContext.Current.Site.OpenWeb("Website_URL"))
{
oWebsite.Title = "New Website
Name";
oWebsite.Update();
}
It is annoying how such small portion of code can cause trouble.
This code works perfectly if your site's language is default language - English for example. But, if you have more than one language installed and you created your site using different language template - for example Croatian, then this code will not work.
To change you site title, you must change title for all languages:
SPUserResource userRes = web.TitleResource; foreach (CultureInfo item in web.SupportedUICultures) {
userRes.SetValueForUICulture(culture,
"My custom site title");
}
Yeah, now it works! Thanks a lot.
ReplyDelete