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:
- void Page_Load(Object o, EventArgs e)
- { if(! Page.IsPostBack)
- {conn=new SqlConnection("server=localhost; uid=sa; pwd=; database=data");
- String sql="select * from student";
- cmd.Fill(ds,"stu");
- 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.
- How to restore a form with a custom control of ASP. NET Server
- Basic concepts of ASP. NET 2.0 Server Control Development
- Analysis on the lifecycle of ASP. NET Server controls
- ASP. NET Server-side control CheckBoxList
- Optimal Selection of ASP. NET Server controls