2011-03-02 20 views

回答

0

他们必须不同的属性:

[ 
PersistenceMode(PersistenceMode.InnerProperty), 
TemplateInstance(TemplateInstance.Single) 
] 
public ITemplate FishBiscuit { get; set; } 

[ 
PersistenceMode(PersistenceMode.InnerProperty), 
TemplateInstance(TemplateInstance.Single) 
] 
public ITemplate FishBiscuit2 { get; set; } 

每个如上定义的模板转换为一个属性,因此它必须有一个匹配的属性名称。

HTH。

2

您选择的方法看起来确实不可能。如果您使用自定义控制的public ITemplate FishBiscuit财产下一标记

<uc:MyControl runat="server"> 
    <FishBiscuit> 
     html1 
    </FishBiscuit> 
    <FishBiscuit> 
     html2 
    </FishBiscuit> 
</uc:MyControl> 

应该实例化只有最后一个模板(html2值)。因此,有两种方法:

  • Brian说要用不同的属性,

  • 或使用像 MultiView你的目的的控制。

看,你上面贴的标记可以转化为:

<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> 

更接近您所提出的标记。

相关问题