protected void btnSetThemeForHost_Click(object sender, EventArgs e)
{
var spContext = SharePointContextProvider.Current.GetSharePointContext(Context);
using (var clientContext = spContext.CreateUserClientContextForSPHost())
{
if (clientContext != null)
{
Web web = clientContext.Web;
string selectedTheme = drpThemes.SelectedValue;
SetThemeBasedOnName(web, selectedTheme);
lblStatus1.Text = string.Format("Theme '{0}' has been applied to the <a href='{1}'>host web</a>.", selectedTheme, spContext.SPHostUrl.ToString());
}
}
}