1

I've got a user control which can be rendered in several different ways depending on the value of one of the properties. For example:

The markup could be:

<h1><asp:Literal id="Title" runat="server" /></h1>
<asp:Literal id="Description" runat="server" />

Or it could be:

<div class="demo" id="box1">
<span><asp:Literal id="Title" runat="server" /></span>
<asp:Image id="LogoImage" runat="server" />
</div>

So the HTML could be very different. I could use a multiview which will allow me to do this, however the annoyance is that in each view I will have to add the literal called "Title" and create a different naming convention for it. Is there a control that supports templates which will allow me to add the literal "Title" to each template? That way in my code I only have to set the value of Title once....

Any ideas anyone?

Thanks in advance Al

higgsy
  • 1,991
  • 8
  • 30
  • 47

1 Answers1

0

Controls that implement the ITemplate interface:

Defines the behavior for populating a templated ASP.NET server control with child controls. The child controls represent the inline templates defined on the page.

You can create your own control with the desired template:

How to: Create Templated ASP.NET User Controls

rick schott
  • 21,012
  • 5
  • 52
  • 81