ASP. NET Server Control Programming

Source: Internet
Author: User
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 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 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 cannot be used. ProgramDirectly control their attributes, usage, and receipt Event , We must also learn other programming languages such as JavaScript to control. For example, <input id = "button1" type = "button" value = "button"/>.

HTML control: This is the control composed of runat = "server" added to the HTML annotation attribute. The difference between HTML annotation and HTML control is obvious, the HTML control is run on the server, and the HTML annotation is run 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 runat = "server" attribute set, the page object will put the control Control Server Code can be controlled. After the control is executed, the execution result of the HTML control is converted to HTML annotation, then, the stream is sent to the client as a string for explanation. For example, .

Asp.net Server Control: Also called Web Server Control. components used to define the Web Application User Interface on ASP pages are the basic of the web forms programming model. Element It will generate 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 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 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 for the HTML control, click this button to send the page back to the server and run 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 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 generally refer to Web controls, that is, Asp.net server controls. Tutorial It also focuses on ASP.net server controls.

In addition, the HTML control is located in system. Web. UI. htmlcontrols, And the Asp.net Server Control is located in 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.