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 ge开发者_开发知识库t 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;
}
}
精彩评论