state management in a custom control RRS feed

  • Question

  • User-1255036730 posted


    I am currently modifying a custom control I created awhile ago.  When looking at some other examples of viewstate I wondered if I did it correctly.  I overrode the SaveViewState and LoadViewState methods.  It looks like I could have just used ViewState["key"] to store everything.  Are there any benefits / disadvantages to using LoadViewState / SaveViewState over ViewState["key"]?

    Friday, June 26, 2009 3:58 PM


  • User1007520750 posted


    I use ViewState["key"] regularly in order to save some data localy until page returns.

    I usualy create a constant for every key so I get better control of the keys that are sometimes spread throughout the page.

    I try not to overload ViewStates with data in order for the page not to be too heavy.

    ViewState["key"] works fine for me. Never manipulated with the SaveViewState and LoadViewState.


    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, June 26, 2009 6:57 PM