Documentation > CMS Template API Library > Asset > SetTemplate(Int32)

SetTemplate

Set a template on an asset. The id must be the id of a folder that contains plugin files such as output.asp or input.aspx, etc.

public System.Boolean SetTemplate(Int32)


Returns

true if the template is changed, false if not

Parameters

NameDescriptionType
templateId The template(folder) id System.Int32

Code Example

C#

Sample:
Asset anAsset = Asset.Load("/Path/ToChange");
Asset template = Asset.Load("/System/Templates/MyTemplate");
if (!anAsset.SetTemplate(template.Id))
{
  Out.DebugWriteLine("Failed to set asset id {0} to new template id {1} error {2}", anAsset.Id, template.Id, context.Error);
}

Connect with Crownpeak