AddTemplateDefinition(templateDef);
//Separator
templateDef = new TemplateDefinition(this, "Separator",
ctl, "SeparatorTemplate", false);
templateGroup.AddTemplateDefinition(templateDef);
//Footer
templateDef = new TemplateDefinition(this, "Footer",
ctl, "FooterTemplate", false);
templateGroup.AddTemplateDefinition(templateDef);
// Add the TemplateGroup to the TemplateGroupCollection
templateGroupCol.Add(templateGroup);
}
return templateGroupCol;
}
}
public override string GetDesignTimeHtml()
{
//Return configuraiton instructions if no templates are set.
if ((null == ((TemplateMenu)Component).HeaderTemplate) &&
(null == ((TemplateMenu)Component).SeparatorTemplate) &&
(null == ((TemplateMenu)Component).FooterTemplate))
{
return CreatePlaceHolderDesignTimeHtml(
"Click here and use the task menu to edit TemplateMenu Header,
Footer, and Seperator template properties. " +
"
A default template is used at run-time if the separator Template is
not specified at design-time." +
"
The Header and Footer templates are optional.");
}
568 CHAPTER 11 ?– DESIGN-TIME SU PPORT
//return configured html
string designTimeHtml = String.Empty;
try
{
((TemplateMenu)Component).DataBind();
designTimeHtml = base.GetDesignTimeHtml();
}
catch (Exception e)
{
designTimeHtml = GetErrorDesignTimeHtml(e);
}
return designTimeHtml;
}
protected override string GetErrorDesignTimeHtml(Exception e)
{
return CreatePlaceHolderDesignTimeHtml(
"There was an error rendering the TemplateMenu control.
Pages:
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742