By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,357 Members | 982 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,357 IT Pros & Developers. It's quick & easy.

Significance of turning the FORM viewstate off

P: n/a
Hi,

I noticed the other day when I was trying to optimise the traffic on a
particular web page that it had significant viewstate even though I had
turned it off for most of the controls. So in a bold step I decided to
attempt to set viewstate on the form itself off which had a massive impact
on the viewstate like 80K to 15k.

So my question is what is the significance of turning off the viewstate for
the form and what information does it hold which would have made such a
drastic reduction.
Thanks.
Aug 8 '08 #1
Share this Question
Share on Google+
6 Replies


P: n/a
every control stores all of its property values in viewstate, so that on
postback, your code does not have to set them to the rendered values. 99% of
the properties are set in the aspx page itself and never change, so saving
them in viewstate is a waste.

except for internal websites (local lan), you should always turn viewstate
off at the page level, and reset any modified value in the oninit of the
postback (normally you'd save these values in session).

-- bruce (sqlwork.com)
"Rain" wrote:
Hi,

I noticed the other day when I was trying to optimise the traffic on a
particular web page that it had significant viewstate even though I had
turned it off for most of the controls. So in a bold step I decided to
attempt to set viewstate on the form itself off which had a massive impact
on the viewstate like 80K to 15k.

So my question is what is the significance of turning off the viewstate for
the form and what information does it hold which would have made such a
drastic reduction.
Thanks.
Aug 8 '08 #2

P: n/a
To add to what Bruce already said. Some controls utilize also control state
(control authors decide if they use it) which cannot be turned off by the
page developer. Control state should be used only for critical stuff which is
required for the control to work correctly. Why I'm saying this is that
control state is also roundtripped in a hidden field like viewstate is.

But effectively: optimizing viewstate should always be done. You already saw
it yourself how much it can have impact.

--
Teemu Keiski
ASP.NET MVP, AspInsider
Finland, EU
"Rain" wrote:
Hi,

I noticed the other day when I was trying to optimise the traffic on a
particular web page that it had significant viewstate even though I had
turned it off for most of the controls. So in a bold step I decided to
attempt to set viewstate on the form itself off which had a massive impact
on the viewstate like 80K to 15k.

So my question is what is the significance of turning off the viewstate for
the form and what information does it hold which would have made such a
drastic reduction.
Thanks.
Aug 9 '08 #3

P: n/a
Thank you for your answer Bruce.

If I turn it off at the page level. Can I then explicitly turn it on control
by control ?

Thanks

"bruce barker" <br*********@discussions.microsoft.comwrote in message
news:85**********************************@microsof t.com...
every control stores all of its property values in viewstate, so that on
postback, your code does not have to set them to the rendered values. 99%
of
the properties are set in the aspx page itself and never change, so saving
them in viewstate is a waste.

except for internal websites (local lan), you should always turn viewstate
off at the page level, and reset any modified value in the oninit of the
postback (normally you'd save these values in session).

-- bruce (sqlwork.com)
"Rain" wrote:
>Hi,

I noticed the other day when I was trying to optimise the traffic on a
particular web page that it had significant viewstate even though I had
turned it off for most of the controls. So in a bold step I decided to
attempt to set viewstate on the form itself off which had a massive
impact
on the viewstate like 80K to 15k.

So my question is what is the significance of turning off the viewstate
for
the form and what information does it hold which would have made such a
drastic reduction.
Thanks.

Aug 10 '08 #4

P: n/a
re:
!If I turn it off at the page level. Can I then explicitly turn it on control by control ?

If you turn it off for the page, no controls on the page will be able to
access that page's viewstate...because viewstate won't exist for that page.


Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
======================================
"Rain" <me@myplace.comwrote in message news:%2******************@TK2MSFTNGP04.phx.gbl...
Thank you for your answer Bruce.

If I turn it off at the page level. Can I then explicitly turn it on control by control ?

Thanks

"bruce barker" <br*********@discussions.microsoft.comwrote in message
news:85**********************************@microsof t.com...
>every control stores all of its property values in viewstate, so that on
postback, your code does not have to set them to the rendered values. 99% of
the properties are set in the aspx page itself and never change, so saving
them in viewstate is a waste.

except for internal websites (local lan), you should always turn viewstate
off at the page level, and reset any modified value in the oninit of the
postback (normally you'd save these values in session).

-- bruce (sqlwork.com)
"Rain" wrote:
>>Hi,

I noticed the other day when I was trying to optimise the traffic on a
particular web page that it had significant viewstate even though I had
turned it off for most of the controls. So in a bold step I decided to
attempt to set viewstate on the form itself off which had a massive impact
on the viewstate like 80K to 15k.

So my question is what is the significance of turning off the viewstate for
the form and what information does it hold which would have made such a
drastic reduction.
Thanks.


Aug 10 '08 #5

P: n/a
OK,

Thank you for that Julian.


"Juan T. Llibre" <no***********@nowhere.comwrote in message
news:OW****************@TK2MSFTNGP02.phx.gbl...
re:
!If I turn it off at the page level. Can I then explicitly turn it on
control by control ?

If you turn it off for the page, no controls on the page will be able to
access that page's viewstate...because viewstate won't exist for that
page.


Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
======================================
"Rain" <me@myplace.comwrote in message
news:%2******************@TK2MSFTNGP04.phx.gbl...
>Thank you for your answer Bruce.

If I turn it off at the page level. Can I then explicitly turn it on
control by control ?

Thanks

"bruce barker" <br*********@discussions.microsoft.comwrote in message
news:85**********************************@microso ft.com...
>>every control stores all of its property values in viewstate, so that on
postback, your code does not have to set them to the rendered values.
99% of
the properties are set in the aspx page itself and never change, so
saving
them in viewstate is a waste.

except for internal websites (local lan), you should always turn
viewstate
off at the page level, and reset any modified value in the oninit of the
postback (normally you'd save these values in session).

-- bruce (sqlwork.com)
"Rain" wrote:

Hi,

I noticed the other day when I was trying to optimise the traffic on a
particular web page that it had significant viewstate even though I had
turned it off for most of the controls. So in a bold step I decided to
attempt to set viewstate on the form itself off which had a massive
impact
on the viewstate like 80K to 15k.

So my question is what is the significance of turning off the viewstate
for
the form and what information does it hold which would have made such a
drastic reduction.
Thanks.



Aug 10 '08 #6

P: n/a
Thanks for that Teemu. I had never heard of control state before. Ill look
it up.
"Teemu Keiski" <jo****@aspalliance.comwrote in message
news:7D**********************************@microsof t.com...
To add to what Bruce already said. Some controls utilize also control
state
(control authors decide if they use it) which cannot be turned off by the
page developer. Control state should be used only for critical stuff which
is
required for the control to work correctly. Why I'm saying this is that
control state is also roundtripped in a hidden field like viewstate is.

But effectively: optimizing viewstate should always be done. You already
saw
it yourself how much it can have impact.

--
Teemu Keiski
ASP.NET MVP, AspInsider
Finland, EU
"Rain" wrote:
>Hi,

I noticed the other day when I was trying to optimise the traffic on a
particular web page that it had significant viewstate even though I had
turned it off for most of the controls. So in a bold step I decided to
attempt to set viewstate on the form itself off which had a massive
impact
on the viewstate like 80K to 15k.

So my question is what is the significance of turning off the viewstate
for
the form and what information does it hold which would have made such a
drastic reduction.
Thanks.

Aug 10 '08 #7

This discussion thread is closed

Replies have been disabled for this discussion.