Quantcast
Viewing all articles
Browse latest Browse all 25064

How to remove a WebPartZone programmatically?

Created a subsite and inserted a webpart in WebPartZone left. But the default.aspx page has the right WebPartZone , which is taking up space. I need eliminate the  WebPartZone right programmatically. Does anyone know how to do this?

            using (SPSite site = new SPSite(fullSiteUrl.Substring(0, siteIndex)))
            {
                using (SPWeb newWeb = site.OpenWeb())
                {
                    newWeb.AllowUnsafeUpdates = true;
                    SPWebCollection subsites = newWeb.Webs;
                    SPWeb newSubWeb = subsites.Add(fullSiteUrl.Substring(siteIndex + 1), siteName, "", 1033, "STS#1", true, false);
                    newWeb.Update();

                    SPLimitedWebPartManager webParts = newSubWeb.GetLimitedWebPartManager(fullSiteUrl + "/default.aspx", System.Web.UI.WebControls.WebParts.PersonalizationScope.Shared);

                    AnunciosWP wp = new AnunciosWP();
                    wp.Title = "Anúncios";
                    wp.WebSite = urlList;
                    wp.SubSiteId = subSiteId;                    

                    webParts.AddWebPart(wp, "Left", 0);
                    webParts.SaveChanges(wp);
                }
            }


Willian Fakri Bratkauskas


Viewing all articles
Browse latest Browse all 25064

Trending Articles