Get root parent site of current site
-
06-12-2019 - |
Domanda
Is there a way to get the root parent site, no matter how many levels deep you are in sub-sites? For example, in this structure:
- MySiteCollection
- MyRootSite
- MySubSite
- MySubSiteOfSubsite
-AnotherSubSite
So in the above example, I need to get the title property of the MyRootSite
web site (not the MySiteCollection
title) no matter which sub-site I'm in. I'm thinking server-side code needs to traverse the parent(s) and get the web site one before IsRootWeb becomes true. Is this correct?
Thanks.
Soluzione
SPSite.RootWeb
is the object you're after, in server side code ( http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spsite.rootweb.aspx).
SP.Site.get_rootWeb()
in client object model code ( http://msdn.microsoft.com/en-us/library/ee552834.aspx).
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a sharepoint.stackexchange