Get SharePoint site ID just created
I've created a sharepoint site using the code below, and I want to get the ID from the site the I've created, how can i do that??? using (SPSite oSPSite = SPContext.Current.Site) { using (SPWeb oSPWeb= oSPSite.OpenWeb()) { oSPWeb.AllowUnsafeUpdates = true; oSPWeb.Webs.Add("Programas/ProCap", "Programa Capacitacion", "", 1033, SPWebTemplate.WebTemplateSTS, true, true); oSPWeb.Update(); oSPWeb.AllowUnsafeUpdates = false; } }
May 13th, 2011 12:26pm

Thsi should give you web Id using (SPSite oSPSite = SPContext.Current.Site) { using (SPWeb oSPWeb= oSPSite.OpenWeb()) { String siteUrl = "Programas/ProCap"; oSPWeb.AllowUnsafeUpdates = true; oSPWeb.Webs.Add(siteUrl, "Programa Capacitacion", "", 1033, SPWebTemplate.WebTemplateSTS, true, true); oSPWeb.Update(); oSPWeb.AllowUnsafeUpdates = false; SPWeb web = oSPSite.OpenWeb(siteUrl); Guid webId = web.ID; //Make sure you dispose the SPWeb object } } There are other ways to do this. Since you have most of the code written, I had added couple of lines to it. :) V
Free Windows Admin Tool Kit Click here and download it now
May 13th, 2011 1:04pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics