Brief Introduction to ASP.net server controls

Source: Internet
Author: User

ASP. NET Server controlsIs a server component that encapsulates the user interface and its related functions. For some related articles, you can refer to the two articles, ASP. NET Server Control View analysis and ASP. NET Server Control for ASP. NET Component Design and learning.

As we all know, every server control creates corresponding objects on the server end at the cost of resources on the server end. Excessive use of server controls will greatly affect the program performance. However, the convenience and functions of server controls are incomparable to those of html controls.

The Status view attribute of the server control can automatically maintain the status of the server control during the page round-trip process, reducing developers' workload, but occupying a large amount of server memory resources. Therefore, when the server control status view is not required, set its EnableViewState attribute to false, such as common controls and controls.

Page. IsPostBack is used to record whether a Page is returned from the client. If it is set to false, it indicates that the Page is run for the first time. Otherwise, it indicates that the Page is returned from the client again.

Reasonable Application of Page. IsPostBack can avoid unnecessary operations during the round-trip process. This attribute can be used in the Page_Load function and some event functions that only need to be initialized once to improve application performance.

 
 
  1. void Page_Load(Object o, EventArgs e)   
  2. { if(! Page.IsPostBack)  
  3. {conn=new SqlConnection("server=localhost; uid=sa; pwd=; database=data");  
  4. String sql="select * from student";  
  5. cmd.Fill(ds,"stu");  
  6. mydataGrid.DataBind();    
  7. }  

The DataGrid Control has the most powerful data display function and has many built-in functions such as data modification, deletion, addition, and paging. If you only need to simply display the data, the DataGrid is not the best choice. The paging function and data storage method of the DataGrid Control (stored in viewstate) make it easy and convenient for program developers to use, but the resulting performance overhead is not negligible.

The DataList control has much fewer functions than the DataGrid Control. However, the customization is much stronger. The unique multi-row data display is more convenient. The functions that the DataGrid can implement.

The Repeater control has the least functions, but is very user-defined. Due to the reduction of many functions, the performance of the server is minimized.

Therefore, when you simply need to display the data list, you can select the Repeater or DataList control to achieve the same purpose and reduce the performance overhead.

This article introduces you to the server-related articles. You can view the open channels on this site. I hope this article will help you.

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.