Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I create a SharePoint subsite if one does not exist with Visual Studio?

I'm attempting to create an application for SharePoint.

I would like this application to live as a subsite under the root site collection.

It would be great if I could give this to clients, and just have them deploy the WSP, have the package create a subsite, and then deploy all of my pages and webparts to this subsite.

I've been googling for some time, but can't seem to get an answer.

*ANSWER*

Instances of SPWeb have a .add() method that allows you to create a subsite.

I'm going to create a Feature whose sole purpose is to check for the existence of a "/whatever" subsite at the RootSite level, and if it does not exist create it during the FeatureActivated event.

I am then going to make my other features dependent on this feature to make sure this site exists before deploying to it.

like image 775
Wesley Avatar asked Dec 27 '25 22:12

Wesley


1 Answers

a subsite = SPWeb... so just create one in the site collection programmatically by creating a new SPWeb in the featurereceiver of your solution? Or you can even script it using powershell...

like image 100
Tjassens Avatar answered Dec 30 '25 23:12

Tjassens



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!