We will encounter ASP. NET controls during actual development. Will there be some tips for using ASP. NET controls? Let's take a look:
◆ ASP. NET controls use server-side controls only when necessary
ASP. NET introduces a new control called Web Server Controls running on the Server. In the code, they are often described through the following syntax:
& Lt; asp: TextBox id = "txtLastName" size = "40" runat = "server"/& gt;
They are also known as ASP controls. The server control is indicated by the runat attribute, and its value is always "server ".
By adding the runat attribute, the general HTML control can be easily converted to the server for running. The following is a simple example:
& Lt; input type = "text" id = "txtLastName" size = "40" runat = "server"/& gt;
You can use the name specified in the id attribute to reference controls in the program. You can set attributes and obtain values programmatically. Therefore, server-side processing is flexible.
This flexibility has a certain price. Each Server Control consumes resources on the server. In addition, unless the view state is explicitly disabled by the control, webpage, or application, the control state is included in the hidden field of the view state and will be passed in each delivery, this will cause serious performance degradation.
A good example in this regard is that for applications that control tables on webpages, if you do not need to reference the elements in the table in the code, you can use HTML tables that do not require server processing. We can still place server controls in HTML table cells and reference server controls in code. To reference any table element, such as a specified unit, the entire table must be a server control.
◆ Differences between HyperLink and LinkButton controls used by ASP. NET controls
For Web visitors, the HyperLink and LinkButton controls are the same, but they still have major functional differences.
When a user clicks the control, the HyperLink control will immediately "navigate" the user to the target URL, and the table pieces will not be sent back to the server. The LinkButton control first sends the table to the server, and then navigating the user to the target URL. If server-side processing is required before the target URL is reached, the LinkButton control is used. If server-side processing is not required, you can use the HyperLink control.
The following is an introduction to the use of ASP. NET controls. I hope it will be helpful to you.
- How to Learn the nine steps of ASP. NET
- Analysis of data collection procedures using ASP. NET Techniques
- ASP. NET naming settings
- Analysis on ASP. NET technique to improve application performance
- Use of StringBuilder class in ASP. NET skills