;
}
3.2: Submit the page to the server. At this time, the page resolution is started, and the text attribute of the button is set
"Submit", and then the lifecycle of the page starts. The last page is displayed in front of us.
3.3: click the button on the browser page to submit the page to the server again. The page starts parsing and starts the lifecycle.
In a certain stage (explained later), The Click Event of the button is triggered, the text of the button is set to "empty", and the page is displayed in front of us.
3.4; when we click the button again, we originally wanted to make the button display "Submit", but no matter how many times we click it, the button always displays "clear".
Why?
Because each time the page is submitted, the page parsing result sets the text attribute of the button as "Submit". When the button is clicked for the second time
The text property displays "clear", but once the page is submitted, the page is parsed as it was for the first time and initialized. The click event of the button still finds that the text of the button is "submitted". Because after the last submission, the text attribute of the button-"clear" is not saved (based on HTTP protocol ).
So we can develop it like winform and achieve the desired effect. ASP. NET adopts the "Save status" technology.
4. Save status Technology
In fact, it is also very simple, but every time the page is returned, the status of all settings of the last page is saved in a form string "_ viewstate", which is like this, when the page returns to the client, the server serializes the status of the control in the page into a string,
Send it to the client together. After the client submits the page, the server parses the submitted _ viewstate and deserializes it.
If the status of each control is restored, the status of the last page is displayed.
Then, in the lifecycle of the page, if there is code to modify the control status in the control event, it is triggered at the appropriate time, and then the value of _ viewstate is updated again.
In this way, the control property persistence is complete.
Therefore, when developing custom controls, we often need to display the persistence of the lifecycle control attributes. Viewstate is used.