views:

12

answers:

1

I have a webforms control, my:Repeater, that is an asp:Repeater. I want to make a default template, like:

<my:Repeater>
  <HeaderTemplate>
    My Default Header
  </HeaderTemplate>
  <ItemTemplate>
    My data
  </ItemTemplate>
  <FooterTemplate>
    My Default Footer
  </FooterTemplate>
</my:Repeater>

I want this template to be in some file not writable by the user. If the user just do

<my:Repeater/>

then it should use my default template. However, the user may override one or more of <HeaderTemplate>, <ItemTemplate> or <FooterTemplate>.

Is this possible, and how can I achieve it?

A: 

Hey,

Each template is an ITemplate; you can programmably create a template through code by implementing ITemplate and programmably adding controls to the parent container. In OnInit method, you could setup the default templates, and if the user supplies an ItemTemplate, it, theoretically, should override your template.

Brian
Can you give an example? I don't think I understand you. I am talking about ASPX templates, I mean where the HTML code is generated.
Johan
If you want default templates for a custom control that a user doesn't have to worry about setting, you can't use ASPX templates. They have to be code templates is what I'm trying to explain.
Brian