Asp. NET server Control programming volume the first language

Source: Internet
Author: User

A friend told me: asp.net is convenient and powerful, the key is that it has a powerful set of ASP.net server controls, in asp.net we often encounter HTML annotations, HTML controls, Web controls and asp.net server controls, etc., can you tell the relationship between them? Let's start by distinguishing several concepts that are often used in asp.net development, HTML annotations, HTML controls, Web controls, and ASP.net server controls.

HTML annotation: Is our traditional HTML Hypertext Markup Language, these HTML annotation in the previous static webpage or the webpage can satisfy our demand, the HTML annotation does not have the method to use the program direct to control their attribute, the use method and receives the event, We have to learn other programming languages such as JavaScript in order to control. such as: <input id= "Button1" type= "button" value= "button"/>.

HTML control: This is the HTML annotation above the attributes of the runat= "server", the difference between HTML and HTML controls is obvious, HTML control is running on the server side, HTML annotation is running on the client. Specifically: When the ASP.net Web page executes, it checks for runat attributes, and if the annotation is not set, then the HTML callout is treated as a string and sent to the client, which the client's browser interprets; If the HTML callout has a set runat= " Server property, the Page object puts the control into the controller, which is controlled by the server-side code, waits until the control is executed, converts the results of the HTML control to an HTML callout, and then interprets it as a string stream to the client. such as: <input id= "Button1" type= "button" value= "button" runat= "Server"/>.

asp.net server control: Also called Web server control, the component in the ASP page that defines the Web application user interface is the basic element of the Web Forms programming model, which produces one or more HTML controls according to the client, rather than directly describing HTML elements. such as <asp:button id= "Button2" runat= "Server" text= "button"/>. What is the difference between it and HTML server-side controls, and what are the new features?

1, asp.net server controls provide a more unified programming interface, such as each ASP.net server control has the Text property.

2, hide the difference between clients, so that programmers can put more effort on the business, and do not have to consider whether the client's browser is IE or Firefox, or mobile devices.

3, ASP.net server control can save the state to the viewstate, so that the page from the client back to the server or download from the server to the client process can be saved.

4. Unlike event-handling models, the event handling of HTML annotations and HTML controls is on the client's page, while the ASP.net server control is on the server, for example:

<input id= "Button4" type= "button" value= "button" runat= "Server"/> is an HTML control, when we click this button, the page will not be uploaded back to the server side, The reason is that we did not define a mouse click event for it.

<input id= "Button4" type= "button" value= "button" runat= "Server" onserverclick= "test"/> We added a OnServerClick event to the HTML control, and clicking the button page sends it back to the server side and executes the test (object sender, EventArgs e) method.

<asp:button id= "Button2" runat= "Server" text= "button"/> is a asp.net server control, and we do not define click for it, but when we click, the page is also sent back to the server side.

This shows that the HTML annotation and HTML control events are triggered by the page, and the ASP.net server control is sent back to the server by the page and processed by the server.

The above is a simple introduction to the controls in ASP.net, the Web control we usually say refers to the ASP.net server control, and this tutorial is mainly about ASP.net server controls.

Another: The HTML control is located in the System.web.ui.htmlcontrols,asp.net server control at System.Web.UI.WebControls.

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.