views:

104

answers:

1

I have been trying to find a good guide to create a templated control. I am trying to display a few pictures on several different parts of my website so I wanted to add a template control to allow me to modify the HTML before it renders. Something like:

<cc1:photos runat="server" id="myPhotos">
<photoCell>
    <img src="<%# photo %>" alt="<%# alt %>" /><br /><%# photoText %>
</photoCell>
</cc1:photos>

I then want to be able to print that photoCell a x number of times depending on how many photos that I want to display. The problem is that I can't find any tutorials on this topic that also displays how to print the data several times with different texts/images.

+2  A: 

Have a look at this to create a templated control:

http://msdn.microsoft.com/en-us/library/ms178657.aspx

Also have you considered using a repeater?

Mark Redman
A repeater would go against the general idea, i want to drag-n-drop the code from the toolbox onto a new webpage and just specify the path to the images, if needed, i can change the html rendering as i showed above.The problem is that i have no idea how to render multiple cells, 1 cell / image, onto the webpage.
Patrick
In that case a WebControl is the only way to go (UserControls cannot be "Templated". Another example here: http://dotnetslackers.com/VB_NET/re-17169_Rendering_a_databound_UL_menu.aspx
Mark Redman