<<previous next>>

Site creation

In the previous example we got to know how to find sites and site collections in the browser of SharePoint object model. Here we will find out how to supply collection with one more site.

First thing that needs to be done is to find and flag property AllWebs of a site collection (the way to do it was described in the previous example) and create new script window.

The program will automatically generate the script code:
C#
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Text;
using MAPILab.SharePoint.Explorer.CodeForm;
using MAPILab.SharePoint.Explorer.Utilities.ScriptRunner;

public class Tester
{
    static void Main(
            Microsoft.SharePoint.SPWebCollection allWebs1
            ,MAPILab.SharePoint.Explorer.CodeForm.MLCodeForm thisForm
            ,MAPILab.SharePoint.Explorer.Utilities.ScriptRunner.MLBrowser browser
            )
    {                    
        // Output browser configuration
        //browser.Text = "Browser window";
        //browser.DisplayMode = MAPILab.SharePoint.Explorer.Utilities.ScriptRunner.DisplayMode.Expanded; 
        
        browser.ReturnValue = null;
    }
}
Visual Basic
Imports System
Imports System.Collections.Generic
Imports System.Diagnostics
Imports System.Text
Imports MAPILab.SharePoint.Explorer.CodeForm
Imports MAPILab.SharePoint.Explorer.Utilities.ScriptRunner

Public Class Tester
    Shared Sub Main(ByVal allWebs1 As Microsoft.SharePoint.SPWebCollection, 
                    ByVal thisForm As MAPILab.SharePoint.Explorer.CodeForm.MLCodeForm, 
                    ByVal browser As MAPILab.SharePoint.Explorer.Utilities.ScriptRunner.MLBrowser)        
        
        ' Output browser configuration
        'browser.Text = "Browser window"
        'browser.DisplayMode = MAPILab.SharePoint.Explorer.Utilities.ScriptRunner.DisplayMode.Expanded
                
        browser.ReturnValue = Nothing
    End Sub
End Class

All that has to be done is to call one function SPWebCollection.Add and return the execution result for further investigation:
C#
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Text;
using MAPILab.SharePoint.Explorer.CodeForm;
using MAPILab.SharePoint.Explorer.Utilities.ScriptRunner;

public class Tester
{
    static void Main(
            Microsoft.SharePoint.SPWebCollection allWebs1
            ,MAPILab.SharePoint.Explorer.CodeForm.MLCodeForm thisForm
            ,MAPILab.SharePoint.Explorer.Utilities.ScriptRunner.MLBrowser browser
            )
    {
        allWebs1.Add("Sample");
        
        // Output browser configuration
        //browser.Text = "Browser window";
        //browser.DisplayMode = MAPILab.SharePoint.Explorer.Utilities.ScriptRunner.DisplayMode.Expanded; 
        
        browser.ReturnValue = allWebs1["Sample"];
    }
}
Visual Basic
Imports System
Imports System.Collections.Generic
Imports System.Diagnostics
Imports System.Text
Imports MAPILab.SharePoint.Explorer.CodeForm
Imports MAPILab.SharePoint.Explorer.Utilities.ScriptRunner

Public Class Tester
    Shared Sub Main(ByVal allWebs1 As Microsoft.SharePoint.SPWebCollection, 
                    ByVal thisForm As MAPILab.SharePoint.Explorer.CodeForm.MLCodeForm, 
                    ByVal browser As MAPILab.SharePoint.Explorer.Utilities.ScriptRunner.MLBrowser)
                
        allWebs1.Add("Sample")
        
        ' Output browser configuration
        'browser.Text = "Browser window"
        'browser.DisplayMode = MAPILab.SharePoint.Explorer.Utilities.ScriptRunner.DisplayMode.Expanded
                
        browser.ReturnValue = allWebs1("Sample")
    End Sub
End Class

After executing the script, information about newly created site will be shown in the new browser window. Do not close this window – you will need it in the next example!

Team site


<<previous next>>

Contents

Last edited Nov 23, 2009 at 1:45 PM by EugenMakarkhin, version 7

Comments

No comments yet.