ViewState Problem in Custom Control

N

Nathan Brady

I've developed a control that itself generates child controls dynamically,
and everything works great, including capturing events from child controls,
child controls maintaining their own view state, etc.

My one problem is that any values I add to the ViewState dictionary (I'm
currently adding them in my Page_Load handler) do not survive the postback.
They simply disappear. My control derives from WebControl (which is a
requirement), and everything I can find leads me to believe I should be able
to use ViewState without additional code to save/load it.

As a test, I tried to manually mess with overriding SaveViewState and
LoadViewState. For some reason, the object passed to LoadViewState was always
null.

TIA,
Nathan
 
M

Mike MacMillan

Nathan,
if you've overridden the viewstate handling at the control level, and come
up with a null viewstate collection, perhaps the viewstate is turned off at
the page/control level or the .config file level. if that's not the case,
make sure you're calling the base.SaveViewState() method of you're overriden
viewstate handler...

Mike
 

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

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,024
Latest member
ARDU_PROgrammER

Latest Threads

Top