BrandingAddinWeb.Default.btnSetThemeForHost_Click C# (CSharp) Method

btnSetThemeForHost_Click() protected method

protected btnSetThemeForHost_Click ( object sender, EventArgs e ) : void
sender object
e System.EventArgs
return void
        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());
                }
            }
        }