Is ASP.NET Custom Control the 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, what requires of me:

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

+4
source share
1 answer

Is content an ITemplate property of a user control? Try using this:

 [PersistenceMode(PersistenceMode.InnerDefaultProperty)] 

http://msdn.microsoft.com/en-us/library/system.web.ui.persistencemode.aspx

EDIT: Also, you need to add the [ParseChildren(True, "DEFAULTPROPERTY")] attribute to the control.

+4
source

Source: https://habr.com/ru/post/1312905/


All Articles