[英]ASP.NET Custom Control - Default Template?
I know this is really picky, but can I have one template inside a user control: 我知道这非常挑剔,但我可以在用户控件中有一个模板:
<uc:MyUserControl runat="server" ID="test">
<div><b>Test</b></div>
<asp:PlaceHolder runat="server" id="pH" />
</uc:MyUserControl>
Instead of what I have now which requires me to: 而不是我现在所需要的:
<uc:MyUserControl runat="server" ID="test">
<Content>
<div><b>Test</b></div>
<asp:PlaceHolder runat="server" id="pH" />
</Content>
</uc:MyUserControl>
Basically I want my control to have only one ITemplate inside of it. 基本上我希望我的控件里面只有一个ITemplate。
Content is an ITemplate property of the user control? 内容是用户控件的ITemplate属性? Try using this:
试试这个:
[PersistenceMode(PersistenceMode.InnerDefaultProperty)]
http://msdn.microsoft.com/en-us/library/system.web.ui.persistencemode.aspx http://msdn.microsoft.com/en-us/library/system.web.ui.persistencemode.aspx
EDIT: Plus, you need to add the [ParseChildren(True, "DEFAULTPROPERTY")]
attribute to the control as well. 编辑:另外,您还需要将
[ParseChildren(True, "DEFAULTPROPERTY")]
属性添加到控件中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.