Recursion in CreateChildControls

I

Iain

In my custom control I have overriden CreateChildControls and the first few
lines look like this.

protected override void CreateChildControls()
{
Debug.WriteLine("CreateChildControls", "FeatureList");
Controls.Clear();
..
}

what I am seeing is that the Controls.Clear line indirectly calls
CreateChildControls (the call is through a Get on the Controls collection
from the stack).

Although the controls end up being right, they are created twice which is
hardly efficient. What do I need to do to stop this happening?

Iain
 
I

Iain

In my custom control I have overriden CreateChildControls and the first few
lines look like this.

protected override void CreateChildControls()
{
Debug.WriteLine("CreateChildControls", "FeatureList");
Controls.Clear();
..
}

what I am seeing is that the Controls.Clear line indirectly calls
CreateChildControls (the call is through a Get on the Controls collection
from the stack).

Although the controls end up being right, they are created twice which is
hardly efficient. What do I need to do to stop this happening?

Iain

What a stupid place to post an ASP.NET question. My apologies.

Iain
 

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

Top