public override bool ApplyChanges() { EnsureChildControls(); TitleWebpart.TitleWebpart webPartToEdit = (TitleWebpart.TitleWebpart) this.WebPartToEdit; if (webPartToEdit != null) { webPartToEdit.FirstString = txtTitle1.Text; webPartToEdit.SecondString = txtTitle2.Text; webPartToEdit.FirstBackColorString = txtFirstBackColorBox.Text; webPartToEdit.FirstForeColorString = txtFirstForeColorBox.Text; webPartToEdit.SecondBackColorString = txtSecondBackColorBox.Text; webPartToEdit.SecondForeColorString = txtSecondForeColorBox.Text; webPartToEdit.FirstFontName = drpFirstFonts.SelectedValue; webPartToEdit.FirstFontSize = int.Parse(drpFirstSize.SelectedValue); webPartToEdit.FirstFontItallic = drpFirstItallic.SelectedIndex == 0 ? true : false; webPartToEdit.FirstFontBold = drpFirstBold.SelectedIndex == 0 ? true : false; webPartToEdit.FirstFontUnderline = drpFirstUnderline.SelectedIndex == 0 ? true : false; webPartToEdit.SecondFontName = drpSecondFonts.SelectedValue; webPartToEdit.SecondFontSize = int.Parse(drpSecondSize.SelectedValue); webPartToEdit.SecondFontItallic = drpSecondItallic.SelectedIndex == 0 ? true : false; webPartToEdit.SecondFontBold = drpSecondBold.SelectedIndex == 0 ? true : false; webPartToEdit.SecondFontUnderline = drpSecondUnderline.SelectedIndex == 0 ? true : false; webPartToEdit.IsSyncronised = drpSyncWithStore.SelectedIndex == 0 ? true : false; webPartToEdit.ImageUrl = txtImageUrl.Text; webPartToEdit.ImageStyle = drpImageStyle.SelectedValue; webPartToEdit.IsDebug = chkDebug.Checked; // sync with main storage if (drpSyncWithStore.SelectedValue.ToString().Equals("true")) { using (SPSetttingsProvider prov = new SPSetttingsProvider()) { bool error = prov.SaveSPSetting(webPartToEdit); if (!error && prov.exception != null) { webPartToEdit.Error = prov.exception.ToString(); } } //SPSite site = SPContext.Current.Site; //ThreadPool.QueueUserWorkItem(new WaitCallback(saveSPSettings), new ContextWrapper { _webPartToEdit = webPartToEdit, _webID = site.RootWeb.ID, _siteID = site.ID}); } } return(true); }
public void saveSPSettings(object input) { TitleWebpart.TitleWebpart webPartToEdit = ((ContextWrapper)input)._webPartToEdit; Guid siteID = ((ContextWrapper)input)._siteID; Guid webID = ((ContextWrapper)input)._webID; using (SPSite site = new SPSite(siteID)) { using (SPWeb web = site.OpenWeb(webID)) { using (SPSetttingsProvider prov = new SPSetttingsProvider(site.RootWeb)) { bool error = prov.SaveSPSetting(webPartToEdit); if (!error && prov.exception != null) { webPartToEdit.Error = prov.exception.ToString(); } } } } }