/// <summary> /// Removes web part container from site. Called when the "Remove container from site" button is pressed. /// Expects the AddWebPartContainerToSite method to be run first. /// </summary> private bool RemoveWebPartContainerFromSite() { // Get the web part container WebPartContainerInfo removeContainer = WebPartContainerInfoProvider.GetWebPartContainerInfo("MyNewContainer"); if (removeContainer != null) { int siteId = CMSContext.CurrentSiteID; // Delete the binding WebPartContainerSiteInfoProvider.RemoveContainerFromSite(removeContainer.ContainerID, siteId); return(true); } return(false); }
protected void SaveSites() { // Remove old items string newValues = ValidationHelper.GetString(usSites.Value, null); string items = DataHelper.GetNewItemsInList(newValues, currentValues); if (!String.IsNullOrEmpty(items)) { string[] newItems = items.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries); if (newItems != null) { // Add all new items to site foreach (string item in newItems) { int siteId = ValidationHelper.GetInteger(item, 0); // Remove WebPartContainerSiteInfoProvider.RemoveContainerFromSite(containerId, siteId); } } } // Add new items items = DataHelper.GetNewItemsInList(currentValues, newValues); if (!String.IsNullOrEmpty(items)) { string[] newItems = items.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries); if (newItems != null) { // Add all new items to site foreach (string item in newItems) { int siteId = ValidationHelper.GetInteger(item, 0); // Add WebPartContainerSiteInfoProvider.AddContainerToSite(containerId, siteId); } } } lblInfo.Visible = true; lblInfo.Text = GetString("General.ChangesSaved"); }