Dissemination of the Smart-Guest ASP. NET Basic Series video data sharing

Source: Internet
Author: User
Asp. NET has all the solutions for developing Web applications, including validation, caching, state management, debugging, and deployment. The feature of code writing is separating the page logic from the business logic, separating the program code from the displayed content, making the colorful pages easier to compose. It also makes the program code look cleaner and simpler.

"The dissemination of the wisdom of the basic series of video tutorial ASP." NET is a Microsoft-led Enterprise Web application development technology platform, is one of the most popular web development technology, can develop a variety of complex features of the site. In order to allow zero-based students to learn professional web development technology and benefit from the Internet in the shortest time.

Video playback address: http://www.php.cn/course/623.html

The difficulty of this video is:

First, the principle of ViewState

1. Browser Request Default.aspx page

2. The server-side discovery creates a VIEWSTATE this time will automatically create a name called __viewstate (Double down lines are all uppercase)
The hidden domain whose hidden field value is Base64 encrypted after it is returned to the browser side this encryption process in the page life cycle
The SaveState event in the Saveallstate method is completed

3. When the browser submits the form, the __viewstate hidden field is also submitted to the server at this time, the ReadState event of the page life cycle
The Readallstate method decrypts the encrypted value back to Base64 and finally assigns the value to the viewstate named name.

4. Finally, to manipulate the values in the ViewState

Second, the use of ViewState:

1. Defining ViewState Properties

public int Pagecount{get{return (int) viewstate["PageCount"];} set{viewstate["PageCount"]=value;}}

2. Conditions for using ViewState

If you want to use ViewState, you must have a server-side form tag in the ASPX page (<form runat = "server" >). A form field is required so that a hidden field containing viewstate information can be passed back to the server. Also, the form must be a server-side form, so that the ASP. NET page framework can add hidden fields when the page is executed on the server.

The EnableViewState property value of page is True

The EnableViewState property value of the control is true

3.ViewState places to be aware of

A. When there is a page callback, you do not need to maintain the value of the control to disable ViewState.
B. The index of the ViewState is case-sensitive.
C. ViewState is not a cross-page.

D. In order to be able to be saved in ViewState, the object must be either fluidization or TypeConverter defined.
E. When the TextMode property of a TextBox control is set to password, its state will not be saved in ViewState, which should be for security reasons.
F. Do not use ViewState when the page does not return or redirect or when it is transferred to another page (transfer).

G. Be careful about the ViewState of a control when it is dynamically built.
H. When the ViewState of a program is forbidden, the ViewState of all pages of the program is also banned.
I. ViewState is only persistent when the page is returned to itself.

4. Set ViewState


ViewState can be set in controls, pages, programs, and global configurations. By default, EnableViewState is true. If you want to disable all page ViewState functionality, you can set EnableViewState to False in the program configuration.

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.