Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

<%@ CodeTemplate Language="C#" TargetLanguage="HTML" %>
<%@ Property Name="Title" Type="System.String" Optional="False" Category="Options" Description="Page title." %>
<%@ Property Name="CharSet" Type="System.String" Optional="False" Default="windows-1252" Category="Options" Description="Character set for the page." %>
<%@ Property Name="IncludeMeta" Type="System.Boolean" Default="True" Optional="False" Category="Options" Description="Include meta tags." %>
<html>
<head>
<% if (IncludeMeta) { %>
<meta http-equiv="Content-Type" content="text/html; charset=<%= CharSet %>">
<% } %>
<title><%= Title %></title>
</head>

...

<%@ CodeTemplate Language="C#" TargetLanguage="HTML" %>
<%@ Property Name="Title" Type="System.String" Optional="False" Category="Options" Description="Page title." %>
<%@ Property Name="Placeholder" Type="System.String" Optional="True" Category="Options" Description="Main placeholder text." %>
<%@ Register Name="Header" Template="Header.cst" MergeProperties="True" ExcludeProperties="IncludeMeta" %>
<% OutputHeader(); %>
<body>
<h1><%= Title %></h1>
<p><%= Placeholder %></p>
</body>
</html>
<script runat="template">
public void OutputHeader()
{
   Header header = this.Create<Header>();
   // include the meta tag
   header.IncludeMeta = true;
   // copy all properties with matching name and type to the sub-template instance
   this.CopyPropertiesTo(header);
   // render the sub-template to the current output stream
   header.Render(this.Response);
{color:navy} }
</script>

When you open the master template, the property sheet shows the Title and Placeholder properties defined in the master template, as well as the CharSet property defined in the sub-template (because of the MergeProperties attribute), but not the IncludeMeta property (because of the ExcludeProperties attribute):

...