views:

41

answers:

2

Say I want to create my own listing control, like a repeater.

How can I make it support my own custom tags, i.e. like:

<blah:MyRepeater ID="id1" runat="server">
<Blah property1="234324" />
<midTemplate>
</midTemplate>

</blah:MyRepeater>
+1  A: 

If the property on your control is public, you can add it in your opening tag,

<blah:MyRepeater ID="id1" runat="server" property1="234324" >
HermanTheSheep
+1  A: 

You need to take a look at the ParseChildren and PersistChildren attributes.

Setting ParseChlidren to true and PersistChildren to false will cause the processor to process the items and presist them as properties of the control.

Your control definition should look something like this:

[ParseChildren(true)] 
[PersistChildren(false)]
public class MyRepeater : Control
{
}
Mike J