PlaceHolder, TreeView, UserControl

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?
 
M

Marina

It sounds like you are not readding the controls during the postback like
the message says.
 
S

Scott Allen

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.
 

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