我知道这真的很挑剔,但是我可以在用户控件中使用一个模板吗:
<uc:MyUserControl runat="server" ID="test">
<div><b>Test</b></div>
<asp:PlaceHolder runat="server" id="pH" />
</uc:MyUserControl>
而不是我现在拥有的要求我:
<uc:MyUserControl runat="server" ID="test">
<Content>
<div><b>Test</b></div>
<asp:PlaceHolder runat="server" id="pH" />
</Content>
</uc:MyUserControl>
基本上我希望我的控件里面只有一个 ITemplate。
最佳答案
内容是用户控件的 ITemplate 属性吗?尝试使用这个:
[PersistenceMode(PersistenceMode.InnerDefaultProperty)]
http://msdn.microsoft.com/en-us/library/system.web.ui.persistencemode.aspx
编辑:另外,您还需要将
[ParseChildren(True, "DEFAULTPROPERTY")]
属性添加到控件中。关于c# - ASP.NET 自定义控件 - 默认模板?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/3047962/