tags:

views:

32

answers:

1

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.

+1  A: 

Hey,

Content is an ITemplate property of the user control? Try using this:

[PersistenceMode(PersistenceMode.InnerDefaultProperty)]

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.

Brian
I will accept your answer if you add that I needed [ParseChildren(True, "DEFAULTPROPERTY")] Attribute on the class... The combination of the PersistenceModeAttribute on the Property and the ParseChildrenAttribute on the class.
Bob Fincheimer
Done. Thank you.
Brian