Responsive Ads Here

Thursday, June 7, 2012


Change Site Theme Programatically

A Theme is collection of styles that can be applied to a page, this provides consistent look across pages. SharePoint provides few out of the box themes. You can customize themes or create new theme. Following article has details on how to create new theme:

A SharePoint site theme can be changed prograamatically using SPWeb object. Following code changes the site theme to "Citrus". The list of availabel theme names can be read from "SPTHEMES.XML" file, which is located in "C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\LAYOUTS\1033".


//Open site collection object
using (SPSite oSPSite = new SPSite("http://servaername"))
{

// Open site
using (SPWeb oSPWeb = oSPSite.OpenWeb())
{
oSPWeb.ApplyTheme("Citrus");
oSPWeb.Update();
}
}

No comments:

Post a Comment