SPContentType.DocumentTemplateUrl-Eigenschaft

Ruft ab oder legt die URL zu der Dokumentvorlage für den Inhaltstyp.

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

Syntax

'Declaration
Public ReadOnly Property DocumentTemplateUrl As String
    Get
'Usage
Dim instance As SPContentType
Dim value As String

value = instance.DocumentTemplateUrl
public string DocumentTemplateUrl { get; }

Eigenschaftswert

Typ: System.String
Die URL für die Dokumentvorlage. Der Standardwert ist String.Empty.

Hinweise

Der Wert dieser Eigenschaft ist eine leere Zeichenfolge, wenn keine Dokumentvorlage für den Inhaltstyp vorhanden ist. Andernfalls kann der Wert eine serverrelative URL oder eine absolute URL für die Vorlage sein, je nachdem, ob die Dokumentvorlage auf vorhanden ist die aktuelle Website (serverrelative URL) oder auf einer anderen Website (absolute URL) vorhanden ist.

Bei ein Inhaltstyp in einer Dokumentbibliothek angewendet wird, wird der Inhaltstyp Dokumentvorlage in Formularordner der Bibliothek kopiert. In diesem Fall ist der Wert der Eigenschaft DocumentTemplateUrl immer eine serverrelative URL an.

Beispiele

Das folgende Beispiel ist eine Konsolenanwendung, die einen Verweis auf einem Websiteinhaltstyp und einen Verweis auf eine Kopie des gleichen Inhaltstyps, die in einer Dokumentbibliothek auf der Website angewendet wurde abruft. Die Anwendung der Wert der Eigenschaft DocumentTemplate() und DocumentTemplateUrl -Eigenschaft für jeden Inhaltstyp ausgegeben.

Beachten Sie, die der Beispielcode wird vorausgesetzt, dass ein Inhaltstyp mit dem Namen "Test Vorschlag," eine Dokumentbibliothek mit dem Namen "Testdokumenten", und, die eine Dokumentvorlage für den Inhaltstyp hochgeladen wurde.

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();
        }
    }
}

Die folgende Ausgabe wird in der Konsole angezeigt.

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...

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