Pergunta

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.

Foi útil?

Solução

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).

Licenciado em: CC-BY-SA com atribuição
Não afiliado a sharepoint.stackexchange
scroll top