Share via


SPDocTemplate Class

Represents a document template used in a document library.

Inheritance Hierarchy

System.Object
  Microsoft.SharePoint.SPDocTemplate

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

Syntax

<SharePointPermissionAttribute(SecurityAction.LinkDemand, ObjectModel := True)> _
<SharePointPermissionAttribute(SecurityAction.InheritanceDemand, ObjectModel := True)> _
Public Class SPDocTemplate

Dim instance As SPDocTemplate
[SharePointPermissionAttribute(SecurityAction.LinkDemand, ObjectModel = true)]
[SharePointPermissionAttribute(SecurityAction.InheritanceDemand, ObjectModel = true)]
public class SPDocTemplate

Examples

The following code example iterates through all document templates of the current site and displays information about each template.

The example assumes the existence of an .aspx page that contains a label control, and that the document template for a library exists in the Forms folder of the document library.

This example requires using directives (Imports in Visual Basic) for the Microsoft.SharePoint and Microsoft.SharePoint.Utilities namespaces.

Dim site As SPWeb = SPControl.GetContextWeb(Context)
Dim docTemps As SPDocTemplateCollection = site.DocTemplates
Dim docTemp As SPDocTemplate

For Each docTemp In  docTemps

    Label1.Text += docTemp.DefaultTemplate & " :: " 
        & SPEncode.HtmlEncode(docTemp.Description) _
        & " :: " & SPEncode.HtmlEncode(docTemp.Name) & " :: " 
            & docTemp.Type & "<BR>"

Next docTemp
SPWeb oWebsite = SPContext.Current.Web;
SPDocTemplateCollection collDocTemplates = oWebsite.DocTemplates;
foreach (SPDocTemplate oDocTemplate in collDocTemplates)
{
   Label1.Text += oDocTemplate.DefaultTemplate + " -- " +
   SPEncode.HtmlEncode(oDocTemplate.Description) + " -- " + 
   SPEncode.HtmlEncode(oDocTemplate.Name) + " -- " +
   oDocTemplate.Type + "<BR>";
}

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

See Also

Reference

SPDocTemplate Members

Microsoft.SharePoint Namespace