Monday, March 26, 2012

Instantiate Accordion content

Hi,

I have an accordion with some panes that have custom controls in their content templates.

The accordion is NOT databound ... the contents are static, though viewstate is helping keep track of the values in the custom controls.

When the page is created for the very first time, NOT postback, the accordion panes do not instantiate the user controls until sometime during the OnPreRender stage in the lifecycle.

On subsequent postbacks however, the accordion panes do instantiate their controls during the LoadState stage, due to their presence in ViewState.

How can I make the accordion panes instantiate their content templates earlier than OnPreRender when the page is created for the first time?

The accordion pane's content templates are not dynamic. They are coded into the page markup.

I have tried calling something like Accordion.Panes[0].Content.InstantiateIn(Accordion.Panes[0]) and various combinations at various stages, but I usually ended up just getting duplicate versions of the controls in the wrong places in the page!

I could not find any "EnsureControls()" methods available in the accordion.

Many thanks in advance for your helpful suggestions,

Ben

Hi,
Accordion.Panes[0].FindControl('nothing') will make pane 0 to instantiate its templates. FindControl is an indirect way to call EnsureChildControls.

-yuriy
http://couldbedone.blogspot.com


Yuriy! Thank you so much! I'm relieved!

No comments:

Post a Comment