When can ViewState be disabled in WebServer controls?

K

Ken Varn

I am trying to cut down the amount ViewState data that is passed to the
client browser. I have a number of Web Server Controls on my page, but I am
confused as to when ViewState can be disabled to save on web traffic.

For instance.... I have several drop down listboxes. If I disable
ViewState, then my server side code cannot obtain the selected item when the
form is submitted. The thing that confuses me is that this should be
submitted back as part of the form regardless of the setting for ViewState,
so why is it necessary to enable ViewState to get the selected index? If I
disable ViewState, then the drop down list fails with an exception if I try
to access the SelectedItem.Value property.

The main point of confusion is that I don't have anyway of knowing what I
lose when I disable ViewState for any given control.



--
-----------------------------------
Ken Varn
Senior Software Engineer
Diebold Inc.

EmailID = varnk
Domain = Diebold.com
-----------------------------------
 
B

bruce barker

there is no good answer. each control decides what to store in viewstate and
how necessary it is for postback processing. in the case of the dropdown, it
stores the select list in viewstate, so it can rebuild the list on the
postback. if you take over this in the oninit event, then list will exist
then the postback data event is fired.

-- bruce (sqlwork.com)


"Ken Varn" <nospam> wrote in message
| I am trying to cut down the amount ViewState data that is passed to the
| client browser. I have a number of Web Server Controls on my page, but I
am
| confused as to when ViewState can be disabled to save on web traffic.
|
| For instance.... I have several drop down listboxes. If I disable
| ViewState, then my server side code cannot obtain the selected item when
the
| form is submitted. The thing that confuses me is that this should be
| submitted back as part of the form regardless of the setting for
ViewState,
| so why is it necessary to enable ViewState to get the selected index? If
I
| disable ViewState, then the drop down list fails with an exception if I
try
| to access the SelectedItem.Value property.
|
| The main point of confusion is that I don't have anyway of knowing what I
| lose when I disable ViewState for any given control.
|
|
|
| --
| -----------------------------------
| Ken Varn
| Senior Software Engineer
| Diebold Inc.
|
| EmailID = varnk
| Domain = Diebold.com
| -----------------------------------
|
|
 
B

Brian Pursley

Ken,

I have run into the same problem you have. As a result, I'm working on an
HTTP Module that caches ViewState on the server instead of sending it to the
client.

Here is a link to a page that tells a little about what I am doing and a
free download of the beta version.
http://www.cinlogic.com/CLViewStateServerInfo.aspx

I would be interested in hearing how it works for you.

-Brian
 
A

Alphonse Giambrone

With viewstate disabled, you can still get the post back value by using
Request.Form.GetValues(yourcontrol.UniqueID)

HTH
 
K

Ken Varn

Brian,

I checked out your web site. Your ViewState handler is an interesting
approach. I did not look at the code yet. I am not sure if I need it for
my application, but I may consider it. I am not so sure how well it would
work with a large number of concurrent users.

--
-----------------------------------
Ken Varn
Senior Software Engineer
Diebold Inc.

EmailID = varnk
Domain = Diebold.com
-----------------------------------
Brian Pursley said:
Ken,

I have run into the same problem you have. As a result, I'm working on an
HTTP Module that caches ViewState on the server instead of sending it to the
client.

Here is a link to a page that tells a little about what I am doing and a
free download of the beta version.
http://www.cinlogic.com/CLViewStateServerInfo.aspx

I would be interested in hearing how it works for you.

-Brian
 

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

Members online

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,901
Latest member
Noble71S45

Latest Threads

Top