locked
Viewstate State Management RRS feed

  • Question

  • User-1426063720 posted

    my interviewer ask me to viewsate is server side or client side state management.i said client side.but he ask me viewstate can be set and access in server code ie .cs page. then how can you say that viewstate is client sid.Pls tell me the actual reason

    Saturday, February 23, 2013 4:28 AM

Answers

  • User-1360095595 posted

    Viewstate is used to manage the state of controls so you can have access to them server side.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, February 23, 2013 4:35 AM
  • User1529156464 posted

    I wouldn't say it is serverside nor client side, because the viewstate is carried out between postbacks, you can get the viewstate data both from the server and the client, so I would say it is control state manager, it isn't neither client explicit nor server explicit. so client side means that the info is stored in the client machine, server side information stored in the server, very simple to understand :)

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, February 28, 2013 10:14 PM

All replies

  • User-1360095595 posted

    Viewstate is used to manage the state of controls so you can have access to them server side.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, February 23, 2013 4:35 AM
  • User-1426063720 posted

    so viewstate is access in server side , how ca  i say it is aclient side statemenagement?

    Saturday, February 23, 2013 4:41 AM
  • User-1360095595 posted

    Well it persists the state of controls client side for access on the server. 

    Saturday, February 23, 2013 4:56 AM
  • User-1426063720 posted

    i have a doubt.

    see the exaample

    viewstae["id"]=1; set value in page load

    and save it to db in button click.

    here no controls are used to store viewsate.the how can it say client side?

    Saturday, February 23, 2013 5:02 AM
  • User1529156464 posted

    I wouldn't say it is serverside nor client side, because the viewstate is carried out between postbacks, you can get the viewstate data both from the server and the client, so I would say it is control state manager, it isn't neither client explicit nor server explicit. so client side means that the info is stored in the client machine, server side information stored in the server, very simple to understand :)

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, February 28, 2013 10:14 PM
  • User1529156464 posted

    I would like to add that the reason behind the viewstate is that usually the pages couldn't remember the state of the objects between postbacks, which simply means you have a form that has a dropdown with the property set to generate an autopostback after the selected index is changed, what would happen before was that all of the other controls after the post back would be reset and the information the user filled out would be lost, so now since the objects have a viewstate that information is remembered between postbacks, it actually happens by itself and you don't need to mess with it unless neccessary.

    I hope this clarifies everything for you.

    Thursday, February 28, 2013 10:24 PM
  • User-1338060929 posted

    we can manage server side but only can store client side one time if it set client side we can't clear server side

    Thursday, March 7, 2013 10:28 AM