tags:

views:

147

answers:

1

I am a bit stuck.

I have created a Web user control which renders a Question (I have a question domain object). This Web user control should render itself again for all Child questions of the current question.

Currently I am loading the child questions with LoadControl into the parent control. It works fine the child question controls do not keep viewstate. Nor do they trigger any proper postbacks.

What's the best way to load a web user control again within itself so that viewstate is properly preserved?

I am using VS2005 and ASP.NET 2.0

+1  A: 

I'm going to take a guess that you have a timing issue. You may be loading your child controls too late in the asp.net page lifecycle for them to be loaded into view state. If you are loading your controls on Load, I can almost assure that this is the case. Try loading your controls earlier, perhaps OnInit?

Here is a diagram of the page lifecycle.

smercer
I am loading them if a button is clicked (postback) .. then i bind the repeater which contains the questions. Those questions do the recursion then .. the first level is remembered correctly but the next levels are not
Michal