ITeamplate : parsing children ?

J

Julien

Hi

I'm working on a UserControl which contains all the design html code with placeholders. Then i instanciate the ITemplates in the placeholders.

I have the following code:

<uc1:page id="Layout1" runat="server">
<HeaderTemplate>

</HeaderTemplate>
<LeftColumnTemplate>

</LeftColumnTemplate>
<FooterTemplate>
</FooterTemplate>
</uc1:page>

When i want to use Labels, or any kind of controls in my subTemplate (HeaderTemplate etc ...) : VS.NET don't parse the children of a subTemplate and in code behind, it doesn't instanciate included controls ! Is VS.NET able to parse childrens in a Itemplate control ?

here is the code behind of my user control :
<ParseChildren(True)> _
Public MustInherit Class PageLayout
Inherits System.Web.UI.UserControl

Public WithEvents HeaderContainer As System.Web.UI.WebControls.PlaceHolder
Public WithEvents ColonneDroiteContainer As System.Web.UI.WebControls.PlaceHolder

Private _bandeauHeaderTemplate As ITemplate = Nothing
Private _headerTemplate As ITemplate = Nothing

Public Property HeaderTemplate() As ITemplate
Get
Return _headerTemplate
End Get
Set(ByVal Value As ITemplate)
_headerTemplate = Value
End Set
End Property

Public Property BandeauHeaderTemplate() As ITemplate
Get
Return _bandeauHeaderTemplate
End Get
Set(ByVal Value As ITemplate)
_bandeauHeaderTemplate = Value
End Set
End Property

Protected Overrides Sub CreateChildControls()

If Not HeaderTemplate Is Nothing Then
HeaderTemplate.InstantiateIn(HeaderContainer)
End If

If Not BandeauHeaderTemplate Is Nothing Then
BandeauHeaderTemplate.InstantiateIn(BandeauHeaderContainer)
End If
End Sub

End Class

thanks.
 
J

John Saunders

Julien said:
Hi

I'm working on a UserControl which contains all the design html code with
placeholders. Then i instanciate the ITemplates in the placeholders.

You can't do anything that complicated with a user control. You need to
create a custom control.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,235
Members
46,821
Latest member
AleidaSchi

Latest Threads

Top