SPControlTemplateManager.GetTemplateByName method (String)
Returns the specified rendering template.
Namespace: Microsoft.SharePoint.WebControls
Assembly: Microsoft.SharePoint (in Microsoft.SharePoint.dll)
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.StringThe name of a template that is defined in one of the ascx files in %ProgramFiles%\Common Files\Microsoft Shared\web server extensions\15\TEMPLATE\CONTROLTEMPLATES\.
Return value
Type: System.Web.UI.ITemplate
A rendering template.
Remarks
For more information about rendering templates, see Patterns of Custom Field Rendering, 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