ASP. NET control usage tips

Source: Internet
Author: User

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.

  1. How to Learn the nine steps of ASP. NET
  2. Analysis of data collection procedures using ASP. NET Techniques
  3. ASP. NET naming settings
  4. Analysis on ASP. NET technique to improve application performance
  5. Use of StringBuilder class in ASP. NET skills

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.