SPControlTemplateManager.GetTemplateByName Method

Returns the specified rendering template.

Namespace:  Microsoft.SharePoint.WebControls
Assembly:  Microsoft.SharePoint (in Microsoft.SharePoint.dll)
Available in Sandboxed Solutions: No

Syntax

'Declaration
Public Shared Function GetTemplateByName ( _
    templateName As String _
) As ITemplate
'Usage
Dim templateName As String
Dim returnValue As ITemplate

returnValue = SPControlTemplateManager.GetTemplateByName(templateName)
public static ITemplate GetTemplateByName(
    string templateName
)

Parameters

  • templateName
    Type: System.String

    The name of a template that is defined in one of the ascx files in %ProgramFiles%\Common Files\Microsoft Shared\web server extensions\14\TEMPLATE\CONTROLTEMPLATES\.

Return Value

Type: System.Web.UI.ITemplate
A rendering template.

Remarks

For more information about rendering templates, see How to: Create a Custom Field Type, How to: Create Field Rendering Templates, Mobile Page Rendering System and RenderingTemplate

Examples

The following example shows the GetTemplateByName(String) method used to return a template that renders a list item with a truncated title on a SharePoint Foundation Web page that is accessible to mobile devices.

void RenderListItemForMobile(SPListItem currentItem, SPView currentView, SPList currentList, WebPartMobileAdapter adapter)
{
    SPMobileTemplateContainer container = 
        new SPMobileTemplateContainer { Item = currentItem, View = currentView, List = currentList };
                                                 
    ITemplate template = SPControlTemplateManager. GetTemplateByName("MobileSimpleViewListItemIterator");
    template.InstantiateIn(container);
    adapter.Controls.Add(container);
}

See Also

Reference

SPControlTemplateManager Class

SPControlTemplateManager Members

Microsoft.SharePoint.WebControls Namespace