The difference between a server-side control and a client control of ASP.

Source: Internet
Author: User

server Controls , the control of ASP., control that these controls must be processed by the server, then respond to the user, and the code executes on the server-side interpretation, generating HTML elements based on the user's browser.

The client control , the normal HTML control, uses the script control operation, which is interpreted by the client browser.

Server controls require postback execution, which needs to be initialized when the page is first opened. As indicated by the Runat property, the value of runat is only one value of "Server". By adding the Runat property, a generic HTML control can be easily converted to a server-side run, and here is a simple example: <input type= "text" id= "Txtlastname" size= "All" runat= "Server"/ >

With the name specified in the id attribute, we can refer to the control in the program and programmatically (in the background code) to set the property and get the value. Therefore, the server-side processing mode has greater flexibility.

However, there is a price for this flexibility. Each server-side control consumes resources on the server. In addition, unless the control, Web page, or application explicitly prohibits view state, the control's status is contained in the hidden domain of view, and is passed in each loopback, causing a severe performance degradation.

Client server control: It is actually the HTML control that is added to the control that is composed of runat= "server". Their note differences are run in different ways, HTML controls run on the client, and HTML server controls are running on the server side. Reference: When an ASP. NET page executes, it checks if the label has a runat property, and if the callout is not set, then the HTML callout is treated as a string and sent to the stream waiting to be sent to the client, which is interpreted by the client's browser. If the HTML callout has a set runat= "Server" property, the Page object puts the control into the controller, the server-side code can control it, and then the execution of the HTML server control is converted to an HTML callout when the control is finished. It is then sent to the client as a string stream for interpretation.

Service-side server control: is the basic element of Web Form programming and is unique to ASP. Instead of directly describing HTML elements, it produces one or more HTML controls in accordance with the client's situation. The ASP. NET server control provides a more unified programming interface, hiding the differences between clients, so that programmers can put more effort on the business, rather than to consider whether the client browser is IE or Firefox, or mobile devices, the ASP. NET server control can be saved to viewstate, so that the page It can be saved from the client to the server or downloaded to the client from the server side, and the event processing model is different, and the HTML label and the HTML server control's event handling are on the client's page, while the ASP. NET server control is on the server.

The most intuitive difference between the two controls is that when the Web page opens, the button click can jump out of the dialog, at this time off the network, if the client control, you can normally jump out of the dialog box, if it is a server control, the display page cannot be displayed.

The big difference is that the client-side controls just do the processing on the client side, such as judging whether your input is legitimate or not. server controls are the opposite. is to do the processing on the server.

The difference between a server-side control and a client control of ASP.

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.