I also searched in the garden. thinhunan wrote a series, "do you write controls today?", which is quite good. However, I made up my mind to write this series of articles to complete a complete series of component and control.
Some friends told me that the key to the convenience and strength of Asp.net is that it has a powerful set of Asp.net server controls. In Asp.net, we often encounter HTML annotations, can you differentiate between HTML server controls, Web controls, and Asp.net server controls? First, we will distinguish several concepts that are frequently used in Asp.net development, such as HTML tagging, HTML server controls, Web controls, and Asp.net server controls,
HTML tagging: the traditional HTML hypertext markup language. These HTML tagging can meet our needs in previous static webpages or webpages, HTML tagging does not allow programs to directly control their attributes, use methods, and receive events. We must learn other programming languages such as JavaScript to control them. For example, <input id = "button1" type = "button" value = "button"/>.
HTML Server Control: This is the control made up of runat = "server" added to the HTML annotation property mentioned above. As for the differences between HTML annotation and HTML Server Control, the HTML server control runs on the server and the HTML annotation runs on the client. Specifically, when ASP. when the web page is executed, the system checks whether the annotation has the runat attribute. If the annotation is not set, the HTML annotation will be treated as a string and sent to the string stream for sending to the client, the browser of the client will explain it. If the HTML annotation has the set runat = "server" attribute, the page object will put the control into the controller, and the server code will be able to control it, after the control is executed, convert the execution result of the HTML Server Control to HTML annotation and 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 a web server control. components used to define the web application user interface on the ASP page are the basic elements of the web forms programming model, it produces one or more HTML controls based on the client, rather than directly describing HTML elements. For example, <asp: button id = "button2" runat = "server" text = "button"/>. What is the difference between it and the HTML server-side controls and what new features it has?
1. The Asp.net Server Control provides a more unified programming interface. For example, each Asp.net Server Control has the text attribute.
2. Hide the differences between clients. In this way, programmers can focus more on their business without considering whether the client browser is IE, Firefox, or a mobile device.
3. The Asp.net server control can be saved to viewstate, so that the page can be saved when the page is uploaded back from the client to the server or downloaded from the server to the client.
4. Different event processing models: HTML tagging and HTML Server Control event processing are on the client 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 Server Control. Click this button, the page will not be uploaded back to the server, because we have not defined a mouse click event for it.
<Input id = "button4" type = "button" value = "button" runat = "server" onserverclick = "test"/> we added an onserverclick event to the HTML Server Control, click this button to send the page back to the server and run the test (Object sender, eventargs e) method.
<Asp: button id = "button2" runat = "server" text = "button"/> is an Asp.net Server Control and we do not define a click for it. However, when we click, the page is also sent back to the server.
It can be seen that HTML tagging and HTML server control events are triggered by pages, while Asp.net server controls are sent back to the server by pages for processing.
The above is a brief introduction to the controls in Asp.net. We usually refer to the Web controls, that is, the Asp.net server controls. This tutorial also focuses on the Asp.net server controls.
In addition, the HTML Server Control is located in system. Web. UI. htmlcontrols, And the Asp.net Server Control is located in system. Web. UI. webcontrols.
Reference: Asp.net Server Control and component development