When can ViewState be disabled in WebServer controls?

Discussion in 'ASP .Net' started by Ken Varn, Nov 8, 2004.

  1. Ken Varn

    Ken Varn Guest

    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
    -----------------------------------
    Ken Varn, Nov 8, 2004
    #1
    1. Advertising

  2. Ken Varn

    bruce barker Guest

    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
    news:%...
    | 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
    | -----------------------------------
    |
    |
    bruce barker, Nov 8, 2004
    #2
    1. Advertising

  3. 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

    "Ken Varn" <nospam> wrote in message
    news:%...
    >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
    > -----------------------------------
    >
    >
    Brian Pursley, Nov 8, 2004
    #3
  4. With viewstate disabled, you can still get the post back value by using
    Request.Form.GetValues(yourcontrol.UniqueID)

    HTH
    --

    Alphonse Giambrone
    Email: a-giam at customdatasolutions dot us


    "Ken Varn" <nospam> wrote in message
    news:%...
    > 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
    > -----------------------------------
    >
    >
    Alphonse Giambrone, Nov 9, 2004
    #4
  5. Ken Varn

    Ken Varn Guest

    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" <> wrote in message
    news:%...
    > 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
    >
    > "Ken Varn" <nospam> wrote in message
    > news:%...
    > >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
    > > -----------------------------------
    > >
    > >

    >
    >
    Ken Varn, Nov 9, 2004
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. David
    Replies:
    2
    Views:
    331
    Natty Gur
    Jul 31, 2003
  2. =?Utf-8?B?RHVuZQ==?=

    validator controls and disabled controls

    =?Utf-8?B?RHVuZQ==?=, Feb 4, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    690
    Peter Blum
    Feb 4, 2004
  3. Jonas Nilsson

    Cassini webserver and Viewstate

    Jonas Nilsson, Nov 12, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    948
    bruce barker
    Nov 12, 2004
  4. Alejandro Penate-Diaz

    if (control.visible == false) viewstate disabled?

    Alejandro Penate-Diaz, Mar 4, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    2,457
    Alejandro Penate-Diaz
    Mar 4, 2005
  5. Ryan Liu
    Replies:
    1
    Views:
    794
    bruce barker
    Jul 13, 2009
Loading...

Share This Page