473,402 Members | 2,053 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,402 software developers and data experts.

Significance of turning the FORM viewstate off

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
6 1571
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
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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Das | last post by:
Hi all, I'm using Asp.net. Within a form I have declared declared a public variable. When the form is loaded I set the property for the variable. but it doesn't maintain its state on postback. I...
2
by: J. Johnson | last post by:
Is it possible use viewstate to detect if a form's data has changed? I want to prevent duplicate submission of data. Example: On_click event of Submit button: 1. Save viewstate to session....
3
by: foldface | last post by:
Hi I have only just become aware that form values posted to the server don't need to be preserved in viewstate because asp.net preserves them anyway separately from this. 2 questions (1) What is...
2
by: DC Gringo | last post by:
I want to turn off viewstate for an application. I added the code below into my web.config, but I'm still getting lotsa viewstate data in my hidden form field: <configuration> <appSettings>...
12
by: Alan Silver | last post by:
Hello, I have a page that gets passed an ID in the query string. It then uses this ID to pull info out of a database and populate controls on the page. When the page is posted back, the query...
4
by: Lee Chapman | last post by:
Hi, Can anyone tell me why in the code below, the call to ClearChildViewState() has no effect? To paraphrase the code: I'm using view state. I have a textbox and a submit button (and a label...
10
by: Mr Newbie | last post by:
DropDown lists and Listboxes do not appear in the list of controls and values passed back to the server on PostBack in Request.Form object. Can someone confirm this to be correct and possibly...
4
by: John Boy | last post by:
Hi, Can anyone help. This is really doing my nut in. 3 years ASP exp. and now doing .DOT which is a step in the wrong direction. Basically I am left with the code of a guy who has left. When I...
3
by: Miguel Dias Moura | last post by:
Hello, i have a form inserted in a multipage. This multipage has 6 panels. When i finally submit the form a new record in the database is created but the record is allways empty. This is...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.