Current Location:Home - News - . NET News
|
|||
Published:2010.08.04 News Sources:admin Views: | |||
Reduce unnecessary server control
Server controls the convenience and functionality is html control can not be compared. However, each server in the server-side controls are needed to create the object, at the expense of server resources at the expense of excessive use of server controls will greatly the impact of application performance.
In many cases, simply use the html tags or data that is bound to achieve the desired function. For example <asp:Label> control, the use of it to display static information, then it is perfectly possible to achieve a simple tag. If the html controls fail to function to be achieved, and in scripting languages such as javascript, vbscript not realized the situation, before considering options server control.
Disable unnecessary state view
The status of the View property of server control in the page automatically from the process of maintaining the state of server controls to reduce the workload of developers, but would take a lot of server memory resources. Therefore, the state does not require server control view of the case, it should be EnableViewState property set to false, such as the commonly used <asp:Lable> and <asp:Button> control.
Page.IsPostBack use
Page.IsPostBack used to record whether the page returned from the client, if that first run for the false, or that from the client again to return to the page. Page.IsPostBack rational application of the process to avoid the page from some of the unnecessary operation. In the Page_Load function and some only need to initialize an event function are able to use the property to improve application performance.
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 ();))
Above code will ensure that only the first visit to the page to read the database and binding.
Fair use DataGrid control
DataGrid control with the most powerful data display capabilities, but also built on the data, modify, delete, add, paging, and many other features. If you simply display data, DataGrid is not the best choice. DataGrid control, paging, data is stored (stored in the viewstate in), etc., while a convenient for application developers, but the resulting performance overhead can not be overlooked.
DataList control is much less than the DataGrid functionality. But a lot of custom is strong. Unique multi-line data is quite easy. DataGrid can realize the function, it can basically achieve.
Repeater control function at least, but the custom is very strong. By reducing the number of features, performance on the server to bring the minimum consumption.
Therefore, simply display the data list, select Repeater or DataList control to achieve the same purpose, but also reduce the performance overhead. |
|||
This Paper Is Divided Into 1 Page | |||
|
|||