ViewState question

D

DougS

I have two panels to which I'm dynamically adding user controls (that
contain text boxes). I want to hide panel one as the user is editing data in
panel two. And vice versa.

I'm loading the controls in each panel on PageLoad

If NOT me.ispostback Then
LoadPanel1()
LoadPanel2()
End If

I have two images that toggle visibility for the panels. I have
EnabledViewState = True for both panels. But when I click on the images they
both lose all their controls. Or at least I cant see them. What am I doing
wrong? Also, I want it to retain the values in the text boxes when they are
toggled.

Thanks,
Doug
 
K

Karl Seguin

Whole control's arent' added to viewstate. Only state information is.

The controls need to be re-created/added on postback. Typically in the
Init() event if you want their state to be preserved.

Alternatively, you can use Denis Bauer's free dynamica placeholder to take
care of this for you:
http://www.denisbauer.com/ASPNETControls/DynamicControlsPlaceholder.aspx

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is
annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)
 

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