Свойство SPContentType.DocumentTemplateUrl
Получает или задает URL-адрес шаблона документа для типа содержимого.
Пространство имен: Microsoft.SharePoint
Сборка: Microsoft.SharePoint (в Microsoft.SharePoint.dll)
Синтаксис
'Декларация
Public ReadOnly Property DocumentTemplateUrl As String
Get
'Применение
Dim instance As SPContentType
Dim value As String
value = instance.DocumentTemplateUrl
public string DocumentTemplateUrl { get; }
Значение свойства
Тип: System.String
URL-адрес шаблона документа. Значение по умолчанию — String.Empty.
Замечания
Значение этого свойства является пустая строка, если шаблон документа не существует для типа содержимого. В противном случае — значение может быть URL-адрес относительно сервера или абсолютный URL-адрес для шаблона, в зависимости от того, существует ли шаблон документа для текущего веб-узла (URL-адрес относительно сервера) или существует на другом сайте (абсолютный URL-адрес).
При применении тип содержимого в библиотеку шаблона типа контента документа копируется в папку форм библиотеки. В этом случае значение свойства DocumentTemplateUrl всегда является URL-адрес относительно сервера.
Примеры
Следующий пример является консольным приложением, которое возвращает ссылку на тип контента сайта и ссылка на копию тем же типом содержимого, которая была применена к библиотеке документов на узле. Затем приложение выводит значение свойства DocumentTemplate() и DocumentTemplateUrl свойства каждого типа контента.
Обратите внимание, что в примере кода предполагается существование типа содержимого с именем «План тестирования,» библиотеки документов с именем «Документы теста», и был загружен шаблон документа для типа содержимого.
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 contentTypeName As String = "Test Proposal"
Dim libraryName As String = "Test Documents"
' Get a reference to a site content type.
Dim siteContentType As SPContentType = oSPWeb.ContentTypes(contentTypeName)
Console.WriteLine("Site content type")
Console.WriteLine("Content type: " + siteContentType.Name)
Console.WriteLine("Document template: " + siteContentType.DocumentTemplate)
Console.WriteLine("Document template Url: " + siteContentType.DocumentTemplateUrl)
Console.WriteLine()
' Get a reference to the same content type after it is applied to a list.
Dim list As SPList = oSPWeb.Lists(libraryName)
Dim listContentType As SPContentType = list.ContentTypes(contentTypeName)
Console.WriteLine("List content type")
Console.WriteLine("Content type: " + listContentType.Name)
Console.WriteLine("Document template: " + listContentType.DocumentTemplate)
Console.WriteLine("Document template Url: " + listContentType.DocumentTemplateUrl)
oSPWeb.Dispose()
oSPSite.Dispose()
Console.WriteLine()
Console.Write("Press ENTER to continue...")
Console.ReadLine()
End Sub
End Module
using System;
using Microsoft.SharePoint;
namespace Test
{
class ConsoleApp
{
static void Main(string[] args)
{
Console.WriteLine();
SPSite oSPSite = new SPSite("https://localhost");
SPWeb oSPWeb = oSPSite.OpenWeb();
string contentTypeName = "Test Proposal";
string libraryName = "Test Documents";
// Get a reference to a site content type.
SPContentType siteContentType = oSPWeb.ContentTypes[contentTypeName];
Console.WriteLine("Site content type");
Console.WriteLine("Content type: " + siteContentType.Name);
Console.WriteLine("Document template: " + siteContentType.DocumentTemplate);
Console.WriteLine("Document template Url: " + siteContentType.DocumentTemplateUrl);
Console.WriteLine();
// Get a reference to the same content type after it is applied to a list.
SPList list = oSPWeb.Lists[libraryName];
SPContentType listContentType = list.ContentTypes[contentTypeName];
Console.WriteLine("List content type");
Console.WriteLine("Content type: " + listContentType.Name);
Console.WriteLine("Document template: " + listContentType.DocumentTemplate);
Console.WriteLine("Document template Url: " + listContentType.DocumentTemplateUrl);
oSPWeb.Dispose();
oSPSite.Dispose();
Console.WriteLine();
Console.Write("Press ENTER to continue...");
Console.ReadLine();
}
}
}
В консоли приложение выведет следующие данные:
Site content type
Content type: Test Proposal
Document template: Test Proposal.dotx
Document template Url: /_cts/Test Proposal/Test Proposal.dotx
List content type
Content type: Test Proposal
Document template: Test Proposal.dotx
Document template Url: /Test Documents/Forms/Test Proposal/Test Proposal.dotx
Press ENTER to continue...
См. также
Справочные материалы
Пространство имен Microsoft.SharePoint