I currently have:
<uc:MyControl ...>
<Template>
</Template>
</uc:Mycontrol>
I would like
<uc:MyControl ...>
<FishBiscuit>
html
</FishBiscuit>
<FishBi开发者_Python百科scuit>
html
</FishBiscuit>
<FishBiscuit>
html
</FishBiscuit>
<FishBiscuit>
html
</FishBiscuit>
.
.
.
However I'm not sure if it's possible, or how to wire it up if it is. Any ideas?
It really seems impossible with the approach you choose. The next markup
<uc:MyControl runat="server">
<FishBiscuit>
html1
</FishBiscuit>
<FishBiscuit>
html2
</FishBiscuit>
</uc:MyControl>
should instanciate only the last template (html2
value) if you use public ITemplate FishBiscuit
property of your custom control. So, there are two approaches:
to use different properties as Brian said,
or use a control like
MultiView
for your purposes.
See, the markup you posted above could be transformed to:
<asp:MultiView runat="server">
<asp:View runat="server">
html
</asp:View>
<asp:View runat="server">
html
</asp:View>
<asp:View runat="server">
html
</asp:View>
<asp:View runat="server">
html
</asp:View>
</asp:MultiView>
which is closer to the markup proposed by you.
They have to be different properties:
[
PersistenceMode(PersistenceMode.InnerProperty),
TemplateInstance(TemplateInstance.Single)
]
public ITemplate FishBiscuit { get; set; }
[
PersistenceMode(PersistenceMode.InnerProperty),
TemplateInstance(TemplateInstance.Single)
]
public ITemplate FishBiscuit2 { get; set; }
Each template defined above translates to a property, so it has to have a matching property name.
HTH.
精彩评论