The CodeTemplateInfo object
The CodeTemplateInfo object, available through the CodeTemplateInfo property of the CodeTemplate object, gives you information about the current template.
| Property | Returns |
|---|---|
CodeBehind |
The full path to the template's code-behind file, or an empty string if there isn't one. |
ContentHashCode |
A hash code based on the template content and all of its dependencies. |
DateCreated |
The date the template file was created. |
DateModified |
The date the template file was modified. |
Description |
The template's description. |
DirectoryName |
The name of the directory the template is in. |
FileName |
The template's file name. |
FullPath |
The full path to the template. |
Language |
The template's language. |
TargetLanguage |
The template's target language. |
Here's a Visual Basic template that writes some of this information to its output:
<%@ CodeTemplate Language="VB" TargetLanguage="Text" Description="Demonstrates CodeTemplateInfo." %>
<% DumpInfo() %>
<script runat="template">
Public Sub DumpInfo()
Response.WriteLine("Template: {0}", Me.CodeTemplateInfo.FileName)
Response.WriteLine("Description: {0}", Me.CodeTemplateInfo.Description)
Response.WriteLine("Location: {0}", Me.CodeTemplateInfo.FullPath)
Response.WriteLine("Language: {0}", Me.CodeTemplateInfo.Language)
Response.WriteLine("Target Language: {0}", Me.CodeTemplateInfo.TargetLanguage)
End Sub
</script>
The output looks similar to this:
Template: CodeTemplateInfo.cst
Description: Demonstrates CodeTemplateInfo.
Location: C:\CodeTemplateInfo.cst
Language: VB
Target Language: Text