ASP. NET Server Control usage and setting skills

Source: Internet
Author: User

As we all know, the powerful ASP. NET Server control is an important reason for the popularity of ASP. NET. In ASP. NET, we often encounter Html tagging, Html controls, Web controls, and ASP. NET Server controls. However, every ASP.. NET Server controls create corresponding objects on the server, all at the cost of sacrificing server resources, excessive use of ASP. NET server controls will greatly affect program performance. Therefore, you must set the ASP. NET Server Control.

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

The commonly used control Page. IsPostBack is used to record whether the Page is returned from the client. If it is set to false, it indicates the first operation; 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, for example:

 
 
  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();  }} 

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.

Using the above ASP. NET Server controls will greatly improve the performance of ASP. NET programs.

  1. How to restore a form with a custom control of ASP. NET Server
  2. Basic concepts of ASP. NET 2.0 Server Control Development
  3. Analysis on the lifecycle of ASP. NET Server controls
  4. ASP. NET Server-side control CheckBoxList
  5. Optimal Selection of ASP. NET Server controls

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.