protected void btnDeployTheme_Click(object sender, EventArgs e)
{
var spContext = SharePointContextProvider.Current.GetSharePointContext(Context);
using (var clientContext = spContext.CreateUserClientContextForSPHost())
{
if (clientContext != null)
{
Web web = clientContext.Web;
// Let's first upload the custom theme to host web
DeployContosoThemeToWeb(web, "MyCustomTheme",
HostingEnvironment.MapPath(string.Format("~/{0}", "Resources/custom.spcolor")),
string.Empty,
HostingEnvironment.MapPath(string.Format("~/{0}", "Resources/custombg.jpg")),
string.Empty);
// Setting the Custom theme to host web
SetThemeBasedOnName(web, "MyCustomTheme");
lblStatus2.Text = string.Format("Custom theme called 'MyCustomTheme' has been uploaded and applied to the <a href='{0}'>host web</a>.", spContext.SPHostUrl.ToString());
}
}
}