views:

169

answers:

1

I haven’t yet started learning Asp.Net 4.0, but I did read a bit on ViewState, where there is a new property ViewStateMode. In earlier versions of Asp.Net, if parent control had its ViewState disabled, then child controls also had their ViewState disabled, even if their EnableViewState was set to true.

a) Thus if I understand it correctly, then a child control C having ViewStateMode property set to “Enable” causes C to save its view state, even if parent control has its view state disabled?

b) Is there a reason why ViewStateMode property hasn’t/couldn’t be implemented in earlier versions of Asp.Net?

thanx

+3  A: 

a) correct.

b) It could have but it wasn't. And EnableViewState could not be changed w/o breaking existing code.

Henk Holterman
So is in Asp.Net 4.0 EnableViewState property obsolete or omitted?
AspOnMyNet
obsolete _and_ omitted (in new code).
Henk Holterman
Uhm, what do you mean that it is omitted in new code? So Asp.Net 4.0 will still somehow allow old apps to use EnableViewstate property, but it won't allow it with new apps?How is that possible?
AspOnMyNet
I meant that you shouldn't use it for new pages. At the same time you're not forced to change existing pages, it works as before.
Henk Holterman
thank you for your help
AspOnMyNet
So Page.EnableViewState = false + Page.ViewStateMode = Disabled + MyControl.EnableViewState = true + MyControl.ViewStateMode = Enabled = MyControl has viewstate ?
Thomas Stock
(It's not crystal clear to me that setting Page.EnableViewStateMode to false will not always override the control's settings.)
Thomas Stock