Click here to Skip to main content
15,900,703 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
how to get content from site template so that i can get lists from main site to subsite?

               using (SPSite site = new SPSite("http://sharepoint2013:40000/sites/customsite/"))
                   using (SPWeb newWeb = site.OpenWeb())

                       SPWebTemplate SiteTemplate = null;
                       SPWebTemplateCollection templateCollection = newWeb.GetAvailableWebTemplates(1033, true);

                       foreach (SPWebTemplate wt in templateCollection)

                           if (wt.Title == "CustomSiteOne")
                               SiteTemplate = wt;
                       string subSiteName = "subSiteOne";

                       newWeb.AllowUnsafeUpdates = true;
                       SPWebCollection subsites = newWeb.Webs;
                       SPWeb newSubWeb = subsites.Add(subSiteName,subSiteName,subSiteName, 1033, SiteTemplate, false, false);
DanielBrownAU 4-Jan-16 17:42pm    
What problem are you actually having?

What is the above cvode doing/not doing as per your expections?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900