i want to not save the view state

A

Adrijan Josic

I have a bunch of user controls that contain TextBoxes,
Repeaters and so on. Some of the user controls even
contain other user controls. The user controls also
usually have some of their properties saved in viewstate.
What I need is: if a user control is not visible it
shouldn't save it's viewstate or the viewstate of the user
controls and server controls it contains and so on
recursively. Im guessing I should override the
SaveViewState method in each of my user controls but I'm
not sure exactly how to do it so that child controls also
lose their viewstate even if they are visible but their
parent is not...

Im sure I could loop through all the parent controls to
see if any of them are not visible to determine is the
control itself visible and the choose to save the view
state, but perhaps there's a better way?

im doing this because most of my user controls are used to
display some result sets when a user clicks somewhere, and
if the user closes them i don't want them to save their
viewstate because I have a lot of them nested and stuff
and eventually when you open them all up once even if you
hide them all they still save a huge viewstate. repeaters
and stuff like that... i can't have 50kb webpages...so I
need to lose their viewstates if they're not visible...

any advice? thanks
 
A

Alex Papadimoulis

Adrijan,

It sounds like you came up with the solution:
Im sure I could loop through all the parent controls to
see if any of them are not visible to determine is the
control itself visible and the choose to save the view
state, but perhaps there's a better way?

There is an EnableViewState page directive, but that will turn it off for
everything ...

Alex Papadimoulis
 

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

Staff online

Members online

Forum statistics

Threads
473,773
Messages
2,569,594
Members
45,118
Latest member
LatishaWhy
Top