| Register
Monday, December 01, 2008
SharePoint Forums
SearchForum Home
     
  SharePoint Development  Begining Web Part Development  how to add a si...
 how to add a site below a site
 
millerthegorilla
7 posts
4th
Joined
6/17/2008

how to add a site below a site
Posted: 17 Jun 08 4:07 AM
In sharepoint you can add a site below the current site by clicking on site actions > create > sites and workspaces.  I'd like to that programatically in a webpart.  What I've done so far is to get the current site (SPSite currentSite = new SPSite(currentUrl);) and then get the webapplication object (SPWebApplication spwa = currentSite.WebApplication;)  I then call spwa.sites.add with the appropriate parameters.  However, sharepoint throws an exception that the site already exists if I give it the url of the current site plus the new site url.  For instance, if the current sites url is 'http://server/personal/admin' and I want to create a site with the url of '/subsite' I've been trying to call spwa.sites.add with the url parameter set to 'http://server/personal/admin/subsite'.  This is when sharepoint complains.  The only way I've been able to create a site is to pass in 'sites/subsite' as the url parameter of spwa.sites.add.  How do I create a site as a subsite of the current site then?
  SharePoint Development  Begining Web Part Development  how to add a si...
(c) 2006 SharePoint Forums   |  Privacy Statement  |  Terms Of Use