Peter's Gekko

Sponsors

The Lounge

Wicked Cool Jobs

News

Advertisement

Images in this post missing? We recently lost them in a site migration. We're working to restore these as you read this. Should you need an image in an emergency, please contact us at imagehelp@codebetter.com
Lost sight of your viewstate ?

In a recent post I blogged on reducing the size of the viewstate. This has been a great success in the project and my default procedure has become to disable a control's viewstate right after dropping it on the form, only to switch it on in the cases I really need it. Like in a dropdownlist, to find out which item was selected by the user. There is a little gotcha here.

When you disable a control's viewstate you also disable it for all child controls in the control tree. When you disable the viewstate of a page, the ultimate control, the viewstate of everything on that page is disabled as well. That's cool, that's easy. When you put a panel on the page and disable it's viewstate everything works well up to the moment you drop a dropdownlist on the panel and try to find out the item selected by the user. The selected item is in the dropdown's viewstate and that viewstate will not work untill you enable the viewstate of the panel-parent of the drop-down. Makes sense in this context but can be somewhat frustrating if you overlook the panel.

blog on,

Peter


Posted Sat, Nov 22 2003 6:45 PM by pvanooijen

[Advertisement]

Add a Comment

(required)  
(optional)
(required)  
Remember Me?
Devlicio.us