PlaceHolder, TreeView, UserControl

  • Thread starter Thread starter Hai Nguyen
  • Start date Start date
H

Hai Nguyen

Hi all

I'm trying ing to create usercontrols dynamically and add them into a
placeholder. During a postback i got the following error

" Failed to load viewstate. The control tree into which viewstate is being
loaded must match the control tree that was used to save viewstate during
the previous request. For example, when adding controls dynamically, the
controls added during a post-back must match the type and position of the
controls added during the initial request. "


Is there any way I can solve this problem?
 
It sounds like you are not readding the controls during the postback like
the message says.
 
Dynamically loading controls is often safer to do during the Init
event, before viewstate loads. Otherwise the viewstate, which is array
indexed, gets out of synch with the controls on the page.
 
Back
Top