Significance of turning the FORM viewstate off

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Rain

    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.


  • =?Utf-8?B?YnJ1Y2UgYmFya2Vy?=

    #2
    RE: Significance of turning the FORM viewstate off

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

    Comment

    • =?Utf-8?B?VGVlbXUgS2Vpc2tp?=

      #3
      RE: Significance of turning the FORM viewstate off

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

      Comment

      • Rain

        #4
        Re: Significance of turning the FORM viewstate off

        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" <brucebarker@di scussions.micro soft.comwrote in message
        news:8515475F-FD96-4C7A-B78F-84DC69271EC3@mi crosoft.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.
        >>
        >>
        >>

        Comment

        • Juan T. Llibre

          #5
          Re: Significance of turning the FORM viewstate off

          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...bec ause 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.com wrote in message news:%23Szzymx% 23IHA.1184@TK2M SFTNGP04.phx.gb l...
          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" <brucebarker@di scussions.micro soft.comwrote in message
          news:8515475F-FD96-4C7A-B78F-84DC69271EC3@mi crosoft.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.
          >>>
          >>>
          >>>
          >
          >

          Comment

          • Rain

            #6
            Re: Significance of turning the FORM viewstate off

            OK,

            Thank you for that Julian.




            "Juan T. Llibre" <nomailreplies@ nowhere.comwrot e in message
            news:OWn09Ay%23 IHA.1296@TK2MSF TNGP02.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...bec ause 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.com wrote in message
            news:%23Szzymx% 23IHA.1184@TK2M SFTNGP04.phx.gb l...
            >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" <brucebarker@di scussions.micro soft.comwrote in message
            >news:8515475 F-FD96-4C7A-B78F-84DC69271EC3@mi crosoft.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.
            >>>>
            >>>>
            >>>>
            >>
            >>
            >
            >

            Comment

            • Rain

              #7
              Re: Significance of turning the FORM viewstate off

              Thanks for that Teemu. I had never heard of control state before. Ill look
              it up.


              "Teemu Keiski" <joteke@aspalli ance.comwrote in message
              news:7D0BFAFB-9E3E-41D5-8C30-184CE05F6665@mi crosoft.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.
              >>
              >>
              >>

              Comment

              Working...