Differences between HTML server controls and Asp.net server controls in Asp.net.

Source: Internet
Author: User
Html Controls: What we traditionally call Html Hypertext markup language. Html Controls can meet our needs in previous static webpages or webpages, Html Control cannot be usedProgramTo directly control their attributes, usage, and receive events, we must learn other Javascript And other programming languages. For example: <Input id = "button1" type = "button" value = "button"/> .

Html Server Control: As mentioned above Html Add Runat = "server" Components, as Html Controls and Html The differences between server controls are obvious, Html The server control is running on the server, Html The control is run on the client. Specifically: When ASP. NET When the webpage is executed, the system checks whether the annotation exists. Runat Attribute. If the annotation is not set Html The control will be treated as a string and sent to the string stream waiting to be sent to the client. The browser of the client will explain it; if Html Controls have settings Runat = "server" Attribute, Page Object will put the control into the controller, server sideCodeYou can control it and wait until the control is executed. Html The execution result of the server control is converted Html Annotation, and then send it as a string stream to the client for explanation. For example: <Input id = "button1" type = "button" value = "button" runat = " Server " /> .

Asp.net Server Control: Also called Web Server Control, ASP Used to define Web The component of the application user interface is Web Forms The basic element of the programming model. Client Produce one or more Html Control, rather than directly describing Html Element. For example <Asp: button id = "button2" runat = "server" text = "button"/> . Then it and Html What are the differences between server-side controls and what are their new features?

1,Asp.netServer controls provide more unified programming interfaces, suchAsp.netAll server controls haveTextAttribute.

2To hide the differences between the client, so that the programmer can focus more on the business, instead of considering that the client browser isIEOrFirefoxOr a mobile device.

3,Asp.netThe server control can save the statusViewstateIn this way, the page can be saved during the process from the client back to the server or from the server to the client.

4Different event processing models,HtmlAnnotation andHtmlThe event processing of the server control is on the client page, andAsp.netThe server control is on the server. For example:

<Input id = "button4" type = "button" value = "button" runat = "server"/>YesHtmlServer Control. Now we click this button, and the page will not be uploaded back to the server, because we didn't define a mouse click event for it.

<Input id = "button4" type = "button" value = "button" runat = "server" onserverclick = "test"/>ForHtmlAddedOnserverclickEvent, click this button to send the page back to the server and executeTest (Object sender, eventargs E)Method.

<Asp: button id = "button2" runat = "server" text = "button"/>YesAsp.netServer Control, which is not definedClickBut when we click, the page will also be sent back to the server.

It can be seen that:HtmlAnnotation andHtmlServer control events are triggered by pages, whileAsp.netThe server control is composedFormSent back to the server for processing.

The above isAsp.netControls inWebControl refersAsp.netServer Control.

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.