Although html controls and web controls have the same functions and look very similar, their internal implementation mechanisms are completely different. Web controls are more efficient than Html controls.
Comparison between html controls and web controls 1: It is quite convenient to use, for example, Button generation:
The Html control gets a huge set of controls to the page. If you use this function, set the attributes as follows:
- < input type=submit/button runat=server>
This will occupy a considerable amount of control resources.
Web controls are integrated into a single function:
- < asp:button id="btnOK" />
This saves the resources occupied by unnecessary controls.
Comparison between html controls and web controls 2: The Web Control has the send-back function. You can use ViewState to maintain the status of the Control. Html control cannot. When you click a page, its status will be lost.
You can do this experiment:
I. Create two files respectively: a.html B. aspx
Ii.add the RadioButton and a button of the Html control on the.html page, and add the RadioButton and a button of the Web Control in B. aspx.
III.a.html directly double-click the browser to run, B. aspx runs through IIS
Iv.in the.html running interface, select RadioButton and click the Button. Then, RadioButton will
Deselect (lose its status), but do the same operation on the B. aspx page, RadioButton will not be lost because ViewState
You can click "View"-> "source file" in the browser menu on the running interface to open the Html code file,
Find the encrypted ViewState, which is similar to the following:
- < input type="hidden" name="_VIEWSTATE" value="dDw0ajfmafmjfzzmj4"/>
In fact, the ViewState implementation principle is to put some information into a hidden control, and the ViewState information generated by asp.net is stored on the client. Note that only when the format is *. aspx file, and the control has properties: "runat = server", the return function can be enabled
Comparison between html controls and web controls 3: The biggest difference between Html controls and Web controls is that they process events differently. When an event is triggered for an Html form control, the browser processes it. However, for a Web control, an event is generated only by the browser, but the browser does not process it. The client sends a message to the server, telling the server to process the event. However, some events, such as pressing the key, moving, or mouse, do not exist in asp.net (because these events are real-time and the server cannot process them timely ), at this time, the Html control will play its role, combined with Html event assistance.
The following are common Html events:
Html control event executed on the browser:
Triggered upon clicking:
- <INPUT type ="Button"Value ="Click Me"Onclick ="Alert (Hi, hello! ');">
Triggered when the mouse is started:
- <INPUT type ="Button"Value ="Click Me"Onmouseup ="Alert (Hi, hello! ');">
Triggered when hovering over the control
- <INPUT type ="Button"Value ="Click Me"Onmouseover ="Alert (Hi, hello! ');">
Triggered when the mouse moves above the control
- <INPUT type ="Button"Value ="Click Me"Onmousemove ="Alert (Hi, hello! ');">
// Triggered when double-clicking the control
- <INPUT type ="Button"Value ="Click Me"Ondblclick ="Alert (Hi, hello! ');">
// Triggered when the focus is on the Control
- <INPUT type ="Button"Value ="Click Me"Onkeypress ="Alert (Hi, hello! ');">
// Triggered when the key is pressed
- <INPUT type ="Button"Value ="Click Me"Onkeydown ="Alert (Hi, hello! ');">
When you do not need to interact with the background, you can use the HTML control. It consumes less resources and is fast. When you need to interact with the background, you can use the WEB control, you can also add runat = "server" to the HTML control to convert an HTML control to an interactive control. However, the resources occupied by the control are no different from those occupied by the Web control.
The WEB control can respond to server events and SET related properties and methods in the background code! HTML is not allowed. WEB server controls need to be processed by the server and then translated into HTML controls and sent to the browser. Therefore, server resources are consumed and IEWSTATE exists, therefore, when sending a message back, the status of the control can be kept or not saved. This increases the amount of information sent back. HTML is directly sent to the browser, which does not consume server resources, but is saved stateless!
To obtain the value of an HTML control, you need to use the FORM method of the REQUEST. The WEB control can be processed directly through attributes!
Therefore, in general, HTML can be used for dynamic processing of controls without the need to save the control status and without any value processing, or you can save the status of the WEB server control! WEB server controls are easy to use, but they consume more server resources!
Many books have said that when considering performance, you should try not to use WEB server controls.
When to use it, you don't have to look at the specific situation. When the conditions are loose, you can look at your habits.
The difference is that if the server control has runat = server, html is not necessary, and web is a waste of resources.
- Principles and Applications of ASP. NET1.1 Verification Code Generation
- Static File Processing: ASP. NET1.1 and ASP. NET2.0 are different.
- Run the windows program (ASP. NET1.1) in ASP. NET)
- Modify the template class for asp. net1.1 Development
- Connect Oracle9i with ASP. NET (ASP. NET1.1)