Creating Subsite(Web)




Go back to index

How to create subsite(web)


Following code block explains how to programmatically create a sub site in a Site Collection

      using System;
      using SPTool.Library;
      
      namespace SPTool.Test
      {
          class Program
          {
              static void Main(string[] args)
              {
                  SPTSite site = new SPTSite("http://sptool/");

                  // Create Web
                  SPTReturn returnObj = site.CreateWeb("Test Web", "Test Description", "/test", "SPS#0", 0, false, false);

                  // Check the status of creating web
                  if (returnObj.State == SPTState.Success)
                  {
                      // Subweb created successfully
                  }
                  else
                  {
                      // Creating sub web failed
                  }
              }
          }
      }
      


Go back to index