SPContentType.ParentWeb-Eigenschaft

Dient zum Abrufen der übergeordneten Website für den Inhaltstyp.

Namespace:  Microsoft.SharePoint
Assembly:  Microsoft.SharePoint (in Microsoft.SharePoint.dll)

Syntax

'Declaration
Public ReadOnly Property ParentWeb As SPWeb
    Get
'Usage
Dim instance As SPContentType
Dim value As SPWeb

value = instance.ParentWeb
public SPWeb ParentWeb { get; }

Eigenschaftswert

Typ: Microsoft.SharePoint.SPWeb
Der übergeordneten Website.

Hinweise

Der Wert der ParentWeb -Eigenschaft ist ein SPWeb -Objekt, das die Website darstellt, in das SPContentType -Objekt vorhanden ist. Der Wert ist für alle SPContentType -Objekte, die an einer beliebigen Stelle innerhalb der Website, unabhängig davon, ob ihr Ebene der Website oder Liste Gültigkeitsbereich vorhanden sind identisch.

Beispiele

Das folgende Beispiel ist eine Konsolenanwendung, die alle Listen in einer Website Drucken des Namens der jede Liste in der Konsole auflistet. Darüber hinaus listet der Beispielcode jede Liste Inhaltstypen, Drucken des Namens der jeder Inhaltstyp für die Konsole als auch eine serverrelative URL für den Inhaltstyp übergeordneten Website.

Imports System
Imports Microsoft.SharePoint

Module ConsoleApp

    Sub Main()
        Console.WriteLine()

        Dim oSPSite As SPSite = New SPSite("https://localhost")
        Dim oSPWeb As SPWeb = oSPSite.OpenWeb()
        Dim oListCollection As SPListCollection = oSPWeb.Lists

        For Each oList As SPList In oListCollection
            Console.WriteLine("List title: " + oList.Title)
            Console.WriteLine()
            For Each oContentType As SPContentType In oList.ContentTypes
                Console.WriteLine("   Content type name: " + oContentType.Name)
                Dim oParent As SPWeb = oContentType.ParentWeb
                Console.WriteLine("   Content type's parent Web: " + oParent.ServerRelativeUrl)
                Console.WriteLine()
                oParent.Dispose()
            Next
        Next

        oSPWeb.Dispose()
        oSPSite.Dispose()

        Console.WriteLine()
        Console.Write("Press ENTER to continue...")
        Console.ReadLine()
    End Sub

End Module
using System;
using Microsoft.SharePoint;

namespace MyTest
{
    class ConsoleApp
    {
        static void Main(string[] args)
        {
            Console.WriteLine();
            SPSite oSPSite = new SPSite("https://localhost");
            SPWeb oSPWeb = oSPSite.OpenWeb();
            SPListCollection oListCollection = oSPWeb.Lists;

            foreach (SPList oList in oListCollection)
            {
                Console.WriteLine("List title: " + oList.Title);
                Console.WriteLine();
                foreach (SPContentType oContentType in oList.ContentTypes)
                {
                    Console.WriteLine("   Content type name: " + oContentType.Name);
                    SPWeb oParent = oContentType.ParentWeb;
                    Console.WriteLine("   Content type's parent Web: " + oParent.ServerRelativeUrl);
                    Console.WriteLine();
                    oParent.Dispose();
                }
                Console.WriteLine();
            }

            oSPWeb.Dispose();
            oSPSite.Dispose();

            Console.Write("Press ENTER to continue...");
            Console.ReadLine();
        }
    }
}

Einige der Ausgabe in der Konsole gedruckt kann folgendermaßen aussehen:

List title: Announcements

   Content type name: Announcement
   Content type's parent Web: /

   Content type name: Folder
   Content type's parent Web: /


List title: Calendar

   Content type name: Event
   Content type's parent Web: /


List title: Links

   Content type name: Link
   Content type's parent Web: /

   Content type name: Folder
   Content type's parent Web: /

Siehe auch

Referenz

SPContentType Klasse

SPContentType-Member

Microsoft.SharePoint-Namespace

Weitere Ressourcen

Introduction to Content Types

Site and List Content Types

Base Content Type Hierarchy