User Tools

Site Tools


Templates in SharePoint 2010

Enumerate web templates:

// 'web' is of type SPWeb
SPWebTemplateCollection templates = web.GetAvailableWebTemplates(web.RegionalSettings.LocaleId);
foreach (SPWebTemplate template in templates)
    // ... use SPWebTemplate properties
    // template.Title
    // template.Name (e.g. STS#1)
    // template.Hidden

Obtain a list template:

SPListTemplateCollection templates = SPContext.Current.Web.ListTemplates;
SPListTemplate template = templates["Template Name"];

Obtain custom templates from the current web:

SPListTemplateCollection customTemplates = 

How to: Find the ID of a SharePoint template using the Server Explorer in Visual Studio.

The Server Explorer allows us to examine contents of a SharePoint site by adding a SharePoint connection. Let's say we want to find the ID of the Announcements list template. At first, we need to select the Announcements template in the Server Explorer:

Then we can display the template properties:

The ID of the  Announcements template is 104 as the Type_Client property indicates.

notes/sharepoint2010/templates.txt · Last modified: 2020/08/26 (external edit)