SPDocTemplate class
Collapse the table of content
Expand the table of content

SPDocTemplate class

Represents a document template used in a document library.


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

public class SPDocTemplate

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.

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>";

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