Свойство SPContentType.ParentWeb
Получает тип содержимого родительского веб-узла.
Пространство имен: Microsoft.SharePoint
Сборка: Microsoft.SharePoint (в Microsoft.SharePoint.dll)
Синтаксис
'Декларация
Public ReadOnly Property ParentWeb As SPWeb
Get
'Применение
Dim instance As SPContentType
Dim value As SPWeb
value = instance.ParentWeb
public SPWeb ParentWeb { get; }
Значение свойства
Тип: Microsoft.SharePoint.SPWeb
Родительского веб-узла.
Замечания
Значение свойства ParentWeb является объект SPWeb , представляющий веб-узел, где существует объект SPContentType . Значение является одинаковым для всех SPContentType объектов, которые существуют в любом веб-узле, независимо от того, находятся ли они на уровне сайта или списка.
Примеры
Следующий пример является консольным приложением, которое перечисляет все списки на сайте Печать имени каждого списка на консоль. Кроме того в примере кода перечисляет каждый список типов содержимого на печать имени каждого типа контента на консоль, а также URL-адрес относительно сервера для родительского типа содержимого веб-узла.
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();
}
}
}
Некоторые выходные данные на консоль выведены может выглядеть следующим образом:
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: /
См. также
Справочные материалы
Пространство имен Microsoft.SharePoint