开发者

Creating default templates on Repeater that are overridable by users

开发者 https://www.devze.com 2023-01-22 00:36 出处:网络
I have a webforms control, my:Repeater, that is an asp:Repeater. I want to make a default template, like:

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?


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消