is there any code example out there that shows me how to get the url for a site if I know the guid?
Currently I have this code to get all sites within the site collection.
private void getSites()
{
SPSite oSiteCollection = SPContext.Current.Site;
SPWebCollection collWebsite = oSiteCollection.AllWebs;
for (int i = 0; i < collWebsite.Count; i++)
{
ddlParentSite.Items.Add(new ListItem(collWebsite[i].Title, collWebsite[i].ID.ToString()));
}
}
Thanks in advance.
SPSite has a GUID constructor
using(SPSite site = new SPSite(guid)) {
return site.Url;
}
And SPSite has a OpenWeb(GUID) method
using(SPSite site = new SPSite("http://somesite")) {
using (SPWeb web = site.OpenWeb(guid)) {
return web.Url;
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With