In this article we will be seeing how to change the site theme in SharePoint using SharePoint object model. Go to Site Actions => Site Settings => Look and Feel => Site theme. Programmatically change the site theme:
namespace ChangeTheme { class Program { static void Main(string[] args) { using (SPSite siteCollection = new SPSite("http://serverName:1111/sites/Sample")) { using (SPWeb web = siteCollection.OpenWeb()) { ThmxTheme theme = ThmxTheme.Open(siteCollection, "_catalogs/theme/Azure.thmx"); theme.ApplyTo(web,false); web.Update(); } } } } }
Build the solution.
Hit F5.
Output:
ThmxTheme class: Represents a Microsoft Office XML theme file. The methods and properties of this class enable read and write operations on the theme name, the color list, and the font list. For more information refer http://msdn.microsoft.com/en-us/library/ee658367.aspx. ThmxTheme.ApplyTo Method (SPWeb, Boolean): Applies the current theme to the given web. . For more information refer http://msdn.microsoft.com/en-us/library/ee659982.aspx
You need to be a premium member to use this feature. To access it, you'll have to upgrade your membership.
Become a sharper developer and jumpstart your career.
$0
$
. 00
monthly
For Basic members:
$20
For Premium members:
$45
For Elite members: