ASP. NET learning notes (14)-view status

Source: Internet
Author: User

The view status is a repository on the ASP. NET page, which stores the values that need to be retained during the sending-back. View status is usually used for page variables that must be retained, rather than for user or session data. For example, you can store view status information. When you send a page to the server next time, the page will be accessed during the page loading activity.

View status data is stored in one or more hidden fields in base64 encoded string format. You can use the viewstate attribute of the page (which exposes a dictionary object) to access the view State information. View State data is stored as strings, so only serialized objects can be stored.

Because the view status is sent as a hidden field, you can change the view status until the prerendercomplete event occurs. Once the page is displayed in the browser, you cannot save changes to the view status.

If you view the page output source, you can see information in the hidden view Status field, which may cause security issues. To alleviate this problem, you canViewstateencryptionmodeSet the property to"AlwaysTo encrypt the view status.

The followingCodeThe example shows how to add an arraylist to the view State.
Viewstate. Add ("arraylistinviewstate", pagearraylist );
Value of the view status:
If (! Viewstate ["sortfield"] = NULL) object o = viewstate ["sortfield"];
Modify the view status value:
Viewstate ["sortfield"] = newvalue;

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.