SPWeb.ApplyTheme Method (Microsoft.SharePoint)
Applies a theme to a Web site.

Namespace: Microsoft.SharePoint
Assembly: Microsoft.SharePoint (in microsoft.sharepoint.dll)
Syntax

Visual Basic (Declaration)
Public Sub ApplyTheme ( _
    strNewTheme As String _
)
Visual Basic (Usage)
Dim instance As SPWeb
Dim strNewTheme As String

instance.ApplyTheme(strNewTheme)
C#
public void ApplyTheme (
    string strNewTheme
)

Parameters

strNewTheme

A string that contains the template ID of a theme that is specified in the SPTHEMES.XML file of the \\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\TEMPLATE\LAYOUTS\Locale_ID folder.

Example

The following code example applies a specified theme to a site in the current site collection.

Visual Basic
Using webSite As SPWeb = SPContext.Current.Site.OpenWeb("Website_URL")
    webSite.ApplyTheme("Theme_ID")
End Using
C#
using (SPWeb oWebsite = SPContext.Current.Site.OpenWeb("Website_URL"))
{
    oWebsite.ApplyTheme("Theme_ID");
}
NoteNote:

Certain objects implement the IDisposable interface, and you must avoid retaining these objects in memory after they are no longer needed. For information about good coding practices, see Best Practices: Using Disposable Windows SharePoint Services Objects.

See Also

Tags :


Page view tracker