- viewstate relies on a dictionary collection
- where each item is indexed with a unique string name
- Using ViewState: ViewState["id"] = 2;
- Retrieving the value from ViewState: int number = (int) ViewState["id"];
- Have to do a type cast to get the value
- ViewState collection stores all items as generic objects
- _ViewState is the Page ViewState.
Don't use view state in the following cases:
- to store mission-critical data that the user cannot be allowed to tamper with.
- to store information that will be used by multiple pages.
- to store an extremely large amount of information, which slows down the page transmission
Note: Any data that you put in the view state will be part of the data stream that goes to the client and then comes back to the server, so be very careful while putting large chunks of data in the ViewState!
No comments:
Post a Comment