Creating Templated Control

S

softsara

I am attempting to create a Templated Control (ASP.NET server control that
inherits from
System.Web.UI.Control).
I have two classes PageContainer and PageTemplateContainer.
PageContainer has a property like this,
[TemplateContainer(typeof(PageTemplateContainer))]
public ITemplate PageTemplate
{
get
{
return pageTemplate;
}
set
{
pageTemplate = value;
}
}

On override method of CreateChildControls like this,

protected override void CreateChildControls ()

{
if (PageTemplate != null)
{
myTemplateContainer = new PageTemplateContainer(this);
PageTemplate.InstantiateIn(myTemplateContainer);
Controls.Add(myTemplateContainer);
}
}

This above method always reads only the first template of PageContainer
Template.
My ASP.Net page code looks like this

<cc1:pageContainer id="PageContainer1" runat="server">
<PageTemplate>
Page1
</PageTemplate>
<PageTemplate>
Page2
</PageTemplate>
<PageTemplate>
Page3
</PageTemplate>
</cc1:pageContainer>


Now I want to render all the PageTemplates which are in ths PageContainer
Template.
What should i do?

Thanx
 
B

Brock Allen

The reason is because you only have one PageTemplate property. You need to
expose a ITemplate Collection to have more than one.
 
S

softsara

Thanx Brock
--
Saravanan M


Brock Allen said:
The reason is because you only have one PageTemplate property. You need to
expose a ITemplate Collection to have more than one.




I am attempting to create a Templated Control (ASP.NET server control
that
inherits from
System.Web.UI.Control).
I have two classes PageContainer and PageTemplateContainer.
PageContainer has a property like this,
[TemplateContainer(typeof(PageTemplateContainer))]
public ITemplate PageTemplate
{
get
{
return pageTemplate;
}
set
{
pageTemplate = value;
}
}
On override method of CreateChildControls like this,

protected override void
CreateChildControls ()

{
if (PageTemplate != null)
{
myTemplateContainer = new PageTemplateContainer(this);
PageTemplate.InstantiateIn(myTemplateContainer);
Controls.Add(myTemplateContainer);
}
}
This above method always reads only the first template of
PageContainer
Template.
My ASP.Net page code looks like this
<cc1:pageContainer id="PageContainer1" runat="server">
<PageTemplate>
Page1
</PageTemplate>
<PageTemplate>
Page2
</PageTemplate>
<PageTemplate>
Page3
</PageTemplate>
</cc1:pageContainer>
Now I want to render all the PageTemplates which are in ths
PageContainer
Template.
What should i do?
Thanx
 

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

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,073
Latest member
DarinCeden

Latest Threads

Top