Asp. NET Server-side control and HTML control comparison

Source: Internet
Author: User

The difference: The server-side control will have a runat= "server" property, so that it can be modified in the background, that is, in the CS code can be modified. For example, when you place an HTML control, the control name is not referenced in the CS code, but the control is referenced in the CS code after adding runat= "Server".

In fact, the server control of ASP. NET returns to the foreground or HTML control after parsing. For example, when you build a page and put a asp:textbox up, and then run the page, viewing the page source file will find that the placed server control becomes the HTML inupt type= "button".

View state refers to: because the HTTP connection is stateless, each page request cannot record information from the last requested page. Then to save the last request on the page control of the value, that is, the page refresh, fill in the value of the same, such as in the textbox filled with a ' a ', the page after the refresh or ' a ',. NET Framework to implement this mechanism, the ViewState view state is used to hold the values of these controls.

But where do the values of these controls exist? Run the program, and then view the source file in the page, we can see an input type= "hidden" name= "__viewstate" tag, this is called "view". It is serialized by the server, and when the server is received again, the values of these hidden fields are deserialized, and then the controls are re-assigned, so that the page refreshes and records the values of all the controls at the time of the last request.

The server control will be saved by default ViewState, it has a property (EnableViewState) can be set, set to Flase do not save, after the page refresh, the value is gone, You can do a test put a TextBox set to EnableViewState to False, and then enter a value, and then use the button to refresh the page, then the textbox will be empty, because there is no view state record to the last value you entered.

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.